-
Notifications
You must be signed in to change notification settings - Fork 1
/
csv.test.js
50 lines (40 loc) · 1.2 KB
/
csv.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const csv = require("./csv");
const BOM = "\ufeff";
describe(csv.csvFromObjectWithBOM, () => {
test("should create semicolor separated csv from object with BOM", () => {
const input = {
one: 1,
two: 2,
three: 3,
pi: "between 3 and 4",
};
const result = csv.csvFromObjectWithBOM(input).replace(BOM, "BOM");
expect(result).toEqual(
`BOM"one";"two";"three";"pi"\r\n1;2;3;"between 3 and 4"`
);
});
});
describe(csv.csvFromObjectWithoutBOM, () => {
test("should create semicolor separated csv from object without BOM", () => {
const input = {
four: true,
five: false,
six: "half a dozen",
};
const result = csv.csvFromObjectWithoutBOM(input);
expect(result).toEqual(`"four";"five";"six"\r\ntrue;false;"half a dozen"`);
});
});
describe(csv.csvFromObjectTransposed, () => {
test("should create transposed semicolor separated csv from object with BOM", () => {
const input = {
four: true,
five: false,
six: "half a dozen",
};
const result = csv.csvFromObjectTransposed(input).replace(BOM, "BOM");
expect(result).toEqual(
`BOM"four";true\r\n"five";false\r\n"six";"half a dozen"`
);
});
});