obdfcascrape/tests/lang.js
Martin Donnelly be5d3eae07 init
2019-05-05 20:13:56 +01:00

53 lines
1.3 KiB
JavaScript

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 cheerio = require('cheerio');
const Sweden = require('../ncas/se');
test('LANGUAGE:: Scrape a Credit Instititute', async t => {
t.test('JSON Stingify and back', async t => {
const psDetail = jsonfile.readFileSync('tests/data/lang.se.json');
const expectedJSON = jsonfile.readFileSync('tests/data/lang.se.json');
const dictionary = new Map(psDetail);
const arrayedMap = JSON.stringify([...dictionary]);
const output = JSON.parse(arrayedMap);
// console.log(output);
t.deepEquals(output, expectedJSON, 'JSON Matches');
t.end();
});
t.test('JSON Stingify -> Buffer and back', async t => {
const psDetail = jsonfile.readFileSync('tests/data/lang.se.json');
const expectedJSON = jsonfile.readFileSync('tests/data/lang.se.json');
const dictionary = new Map(psDetail);
const arrayedMap = JSON.stringify([...dictionary]);
const base64data = new Buffer.from(arrayedMap);
const str = base64data.toString();
const output = JSON.parse(str);
// console.log(output);
t.deepEquals(output, expectedJSON, 'JSON Matches');
t.end();
});
t.end();
});