0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

Added basic test coverage for JSON to CSV serialization

no issue
This commit is contained in:
Nazar Gargol 2020-07-08 19:40:48 +12:00
parent 7f25548be5
commit 4c21bb9d65
2 changed files with 23 additions and 0 deletions

View file

View file

@ -0,0 +1,23 @@
const should = require('should');
const path = require('path');
const {readCSV} = require('../lib/parse');
const unparse = require('../lib/unparse');
const csvPath = path.join(__dirname, '/fixtures/');
describe('unparse', function () {
it('serializes json to CSV and adds standard members fields', async function () {
const filePath = path.join(csvPath, 'single-column-with-header.csv');
const json = await readCSV({
path: filePath,
columnsToExtract: [{name: 'email', lookup: /email/i}]
});
const result = unparse(json);
should.exist(result);
const expected = `id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels\r\n,jbloggs@example.com,,,,,,,,\r\n,test@example.com,,,,,,,,`;
should.equal(result, expected);
});
});