-
Notifications
You must be signed in to change notification settings - Fork 150
/
beyahad-bishvilha.test.ts
52 lines (42 loc) · 1.91 KB
/
beyahad-bishvilha.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import BeyahadBishvilhaScraper from './beyahad-bishvilha';
import {
maybeTestCompanyAPI, extendAsyncTimeout, getTestsConfig, exportTransactions,
} from '../tests/tests-utils';
import { SCRAPERS } from '../definitions';
import { LoginResults } from './base-scraper-with-browser';
const COMPANY_ID = 'beyahadBishvilha'; // TODO this property should be hard-coded in the provider
const testsConfig = getTestsConfig();
describe('Beyahad Bishvilha scraper', () => {
beforeAll(() => {
extendAsyncTimeout(); // The default timeout is 5 seconds per async test, this function extends the timeout value
});
test('should expose login fields in scrapers constant', () => {
expect(SCRAPERS.beyahadBishvilha).toBeDefined();
expect(SCRAPERS.beyahadBishvilha.loginFields).toContain('id');
expect(SCRAPERS.beyahadBishvilha.loginFields).toContain('password');
});
maybeTestCompanyAPI(COMPANY_ID, (config) => config.companyAPI.invalidPassword)('should fail on invalid user/password"', async () => {
const options = {
...testsConfig.options,
companyId: COMPANY_ID,
};
const scraper = new BeyahadBishvilhaScraper(options);
const result = await scraper.scrape({ id: 'e10s12', password: '3f3ss3d' });
expect(result).toBeDefined();
expect(result.success).toBeFalsy();
expect(result.errorType).toBe(LoginResults.InvalidPassword);
});
maybeTestCompanyAPI(COMPANY_ID)('should scrape transactions"', async () => {
const options = {
...testsConfig.options,
companyId: COMPANY_ID,
};
const scraper = new BeyahadBishvilhaScraper(options);
const result = await scraper.scrape(testsConfig.credentials.beyahadBishvilha);
expect(result).toBeDefined();
const error = `${result.errorType || ''} ${result.errorMessage || ''}`.trim();
expect(error).toBe('');
expect(result.success).toBeTruthy();
exportTransactions(COMPANY_ID, result.accounts || []);
});
});