Skip to content

Commit c9a24be

Browse files
committed
ref #6 Added CsvWriter level tests
1 parent 959e1cd commit c9a24be

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

test/unit/write-array-records.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,19 @@ describe('Write array records into CSV', () => {
7979
});
8080
});
8181
});
82+
83+
describe('When semicolon is specified as a field delimiter', () => {
84+
const filePath = makeFilePath('field-delimiter');
85+
const writer = createArrayCsvWriter({
86+
path: filePath,
87+
header: ['NAME', 'LANGUAGE'],
88+
fieldDelimiter: ';'
89+
});
90+
91+
it('writes to a file with the specified encoding', () => {
92+
return writer.writeRecords(records).then(() => {
93+
assertFile(filePath, 'NAME;LANGUAGE\nBob;French\nMary;English\n');
94+
});
95+
});
96+
});
8297
});

test/unit/write-object-records.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,19 @@ describe('Write object records into CSV', () => {
9898
});
9999
});
100100
});
101+
102+
describe('When semicolon is specified as a field delimiter', () => {
103+
const filePath = makeFilePath('field-delimiter');
104+
const writer = createObjectCsvWriter({
105+
path: filePath,
106+
header: [{id: 'name', title: 'NAME'}, {id: 'lang', title: 'LANGUAGE'}],
107+
fieldDelimiter: ';'
108+
});
109+
110+
it('writes to a file with the specified encoding', () => {
111+
return writer.writeRecords(records).then(() => {
112+
assertFile(filePath, 'NAME;LANGUAGE\nBob;French\nMary;English\n');
113+
});
114+
});
115+
});
101116
});

0 commit comments

Comments
 (0)