mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-25 02:31:59 -05:00
Reworked unparse test to use less dependencies
This commit is contained in:
parent
4c21bb9d65
commit
86ff376c99
1 changed files with 6 additions and 10 deletions
|
@ -1,23 +1,19 @@
|
||||||
const should = require('should');
|
const should = require('should');
|
||||||
const path = require('path');
|
|
||||||
const {readCSV} = require('../lib/parse');
|
|
||||||
const unparse = require('../lib/unparse');
|
const unparse = require('../lib/unparse');
|
||||||
const csvPath = path.join(__dirname, '/fixtures/');
|
|
||||||
|
|
||||||
describe('unparse', function () {
|
describe('unparse', function () {
|
||||||
it('serializes json to CSV and adds standard members fields', async 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 = [{
|
||||||
|
email: 'email@example.com',
|
||||||
const json = await readCSV({
|
name: 'Sam Memberino',
|
||||||
path: filePath,
|
note: 'Early supporter'
|
||||||
columnsToExtract: [{name: 'email', lookup: /email/i}]
|
}];
|
||||||
});
|
|
||||||
|
|
||||||
const result = unparse(json);
|
const result = unparse(json);
|
||||||
|
|
||||||
should.exist(result);
|
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,,,,,,,,`;
|
const expected = `id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels\r\n,email@example.com,Sam Memberino,Early supporter,,,,,,`;
|
||||||
should.equal(result, expected);
|
should.equal(result, expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue