Skip to content

Commit

Permalink
ref #6 Added CsvWriter level tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ryu1kn committed Aug 20, 2018
1 parent 959e1cd commit c9a24be
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/unit/write-array-records.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,19 @@ describe('Write array records into CSV', () => {
});
});
});

describe('When semicolon is specified as a field delimiter', () => {
const filePath = makeFilePath('field-delimiter');
const writer = createArrayCsvWriter({
path: filePath,
header: ['NAME', 'LANGUAGE'],
fieldDelimiter: ';'
});

it('writes to a file with the specified encoding', () => {
return writer.writeRecords(records).then(() => {
assertFile(filePath, 'NAME;LANGUAGE\nBob;French\nMary;English\n');
});
});
});
});
15 changes: 15 additions & 0 deletions test/unit/write-object-records.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,19 @@ describe('Write object records into CSV', () => {
});
});
});

describe('When semicolon is specified as a field delimiter', () => {
const filePath = makeFilePath('field-delimiter');
const writer = createObjectCsvWriter({
path: filePath,
header: [{id: 'name', title: 'NAME'}, {id: 'lang', title: 'LANGUAGE'}],
fieldDelimiter: ';'
});

it('writes to a file with the specified encoding', () => {
return writer.writeRecords(records).then(() => {
assertFile(filePath, 'NAME;LANGUAGE\nBob;French\nMary;English\n');
});
});
});
});

0 comments on commit c9a24be

Please sign in to comment.