forked from eshaham/israeli-bank-scrapers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding mercantile bank scraper (eshaham#838)
Co-authored-by: eqqupty <eqqupty@amazon.com> Co-authored-by: Baruch Odem <baruchiro@gmail.com>
- Loading branch information
1 parent
d8c4a57
commit 15bcd26
Showing
6 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import MercantileScraper from './mercantile'; | ||
import { | ||
maybeTestCompanyAPI, extendAsyncTimeout, getTestsConfig, exportTransactions, | ||
} from '../tests/tests-utils'; | ||
import { SCRAPERS } from '../definitions'; | ||
import { LoginResults } from './base-scraper-with-browser'; | ||
|
||
const COMPANY_ID = 'mercantile'; // TODO this property should be hard-coded in the provider | ||
const testsConfig = getTestsConfig(); | ||
|
||
describe('Mercantile legacy 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.mercantile).toBeDefined(); | ||
expect(SCRAPERS.mercantile.loginFields).toContain('id'); | ||
expect(SCRAPERS.mercantile.loginFields).toContain('password'); | ||
expect(SCRAPERS.mercantile.loginFields).toContain('num'); | ||
}); | ||
|
||
maybeTestCompanyAPI(COMPANY_ID, (config) => config.companyAPI.invalidPassword)('should fail on invalid user/password"', async () => { | ||
const options = { | ||
...testsConfig.options, | ||
companyId: COMPANY_ID, | ||
}; | ||
|
||
const scraper = new MercantileScraper(options); | ||
|
||
const result = await scraper.scrape(testsConfig.credentials.mercantile); | ||
|
||
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 MercantileScraper(options); | ||
const result = await scraper.scrape(testsConfig.credentials.mercantile); | ||
expect(result).toBeDefined(); | ||
const error = `${result.errorType || ''} ${result.errorMessage || ''}`.trim(); | ||
expect(error).toBe(''); | ||
expect(result.success).toBeTruthy(); | ||
|
||
exportTransactions(COMPANY_ID, result.accounts || []); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import DiscountScraper from './discount'; | ||
|
||
type ScraperSpecificCredentials = { id: string, password: string, num: string }; | ||
class MercantileScraper extends DiscountScraper { | ||
getLoginOptions(credentials: ScraperSpecificCredentials) { | ||
return { | ||
...super.getLoginOptions(credentials), | ||
loginUrl: 'https://start.telebank.co.il/login/?bank=m', | ||
}; | ||
} | ||
} | ||
|
||
export default MercantileScraper; |