const tape = require('tape'); const _test = require('tape-promise').default; // <---- notice 'default' const test = _test(tape); // decorate tape const fs = require('fs'); const jsonfile = require('jsonfile'); const Germany = require('../ncas/de'); const entityPage = fs.readFileSync('tests/data/de/entity.html'); const ciEntityPage = fs.readFileSync('tests/data/de/ciEntity.html'); const output = { 'description': [ 'real,- Digital Payment & Technology Services GmbHAm Albertussee 1', '40549 Düsseldorf', 'Deutschland' ], 'permissions': { 'original': [ { 'service': 'Akquisitionsgeschäft (§ 1 Abs. 1 Satz 2 Nr. 5 ZAG)', 'startAuth': '13/07/2018', 'endAuth': '' }, { 'service': 'Finanztransfergeschäft (§ 1 Abs. 1 Satz 2 Nr. 6 ZAG)', 'startAuth': '13/07/2018', 'endAuth': '' }, { 'service': 'Finanztransfergeschäft (§ 1 Abs. 2 Nr. 6 ZAG)', 'startAuth': '28/12/2017', 'endAuth': '' }, { 'service': 'Zahlungsauthentifizierungsgeschäft (§ 1 Abs. 2 Nr. 4 ZAG)', 'startAuth': '28/12/2017', 'endAuth': '' } ], 'translated': [ { 'service': 'Acquisition business (§ 1 Abs. 1 Satz 2 Nr. 5 ZAG)', 'startAuth': '13/07/2018', 'endAuth': '' }, { 'service': 'Money transmission services (§ 1 Abs. 1 Satz 2 Nr. 6 ZAG)', 'startAuth': '13/07/2018', 'endAuth': '' }, { 'service': 'Money transmission services (§ 1 Abs. 2 Nr. 6 ZAG)', 'startAuth': '28/12/2017', 'endAuth': '' }, { 'service': 'Payment authentication business (§ 1 Abs. 2 Nr. 4 ZAG)', 'startAuth': '28/12/2017', 'endAuth': '' } ] } }; const failure = { 'fail':true }; const ciOutput = jsonfile.readFileSync('tests/data/de/ciOutput.json'); const dictionaryData = [['Akquisitionsgeschäft', 'Acquisition business'], ['Finanztransfergeschäft', 'Money transmission services'], ['Zahlungsauthentifizierungsgeschäft', 'Payment authentication business'], ['Digitalisiertes Zahlungsgeschäft', 'Digitized payment transaction'], ['Ein- oder Auszahlungsgeschäft', 'Deposit or withdrawal transaction'], ['Lastschriftgeschäft mit Kreditgewährung', 'Direct debit business with lending'], ['Lastschriftgeschäft ohne Kreditgewährung', 'Direct debit business without lending'], ['Zahlungskartengeschäft mit Kreditgewährung', 'Payment card business with credit'], ['Zahlungskartengeschäft ohne Kreditgewährung', 'Payment card business without lending'], ['Überweisungsgeschäft mit Kreditgewährung', 'Credit transfer transaction'], ['Überweisungsgeschäft ohne Kreditgewährung', 'Remittance without credit'], ['Auszahlungsgeschäft', 'Payment business'], ['Einzahlungsgeschäft', 'Deposit business'], ['Kontoinformationsdienste', 'Account information services'], ['Zahlungsauslösedienste', 'Payment release services'], ['Abschlußvermittlung', 'Terminating switch'], ['Anlageberatung', 'Investment advice'], ['Anlagevermittlung', 'Investment brokerage'], ['Anlageverwaltung', ''], ['Depotgeschäft', ''], ['Diskontgeschäft', ''], ['Drittstaateneinlagenvermittlung', ''], ['E-Geld-Geschäft', ''], ['Eigengeschäft', ''], ['Eigenhandel', ''], ['Einlagengeschäft', ''], ['Emissionsgeschäft', ''], ['Factoring', ''], ['Finanzierungsleasing', ''], ['Finanzkommissionsgeschäft', ''], ['Finanzportfolioverwaltung', ''], ['Garantiegeschäft', ''], ['Geldkartengeschäft', ''], ['Girogeschäft', ''], ['Kreditgeschäft', ''], ['Kreditkartengeschäft', ''], ['Netzgeldgeschäft', ''], ['Organisiertes Handelssystem (OTF)', ''], ['Platzierungsgeschäft', ''], ['Revolvinggeschäft, sog.', ''], ['Scheck- u. Wechseleinzugs- u. Reisescheckgeschäft', ''], ['Sortengeschäft', '']]; test('GERMANY::Process Entity', async t => { const deScraper = new Germany(); deScraper.dictionary = new Map(dictionaryData); const result = await deScraper.extractPaymentEntity(entityPage); t.deepEquals(result, output, 'Extract the correct data'); t.end(); }); test('GERMANY::Process CI Entity', async t => { const deScraper = new Germany(); deScraper.dictionary = new Map(dictionaryData); const result = await deScraper.extractPaymentEntity(ciEntityPage); t.deepEquals(result, ciOutput, 'Extract the correct data'); t.end(); }); test('GERMANY::Long filename handling', async t => { const deScraper = new Germany(); deScraper.dictionary = new Map(dictionaryData); const result = deScraper._makeFileName('KreissparkasseSteinfurtZweckverbandssparkassedesKreisesSteinfurtundderStdteundGemeindenAltenbergeGrevenHrstelHopstenHorstmarIbbenbrenLadbergenLaerLienenLotteMetelenMettingenNeuenkirchenNordwaldeReckeSaerbeckSteinfurtTecklenburgWesterkappelnundWettringen'); t.equals(result.length, 209, 'Trim ovely long filename'); t.end(); }); // test('GERMANY::Clean filename handling', async t => { const deScraper = new Germany(); deScraper.dictionary = new Map(dictionaryData); deScraper.mode = 0; const result = deScraper._makeFileName('real,- Digital Payment & Technology Services GmbH'); t.equals(result, 'ps_realDigitalPaymentTechnologyServicesGmbH', 'Clean bad characters from filename'); t.end(); });