-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
117 lines (110 loc) · 2.07 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const Exporter = require('./browser-csv-exporter.min.js');
test('test1', () => {
let exporter = new Exporter({
columns: [{
title: 'Name',
key: 'name'
}, {
title: 'Age',
key: 'age'
}],
data: [{
name: 'A',
age: 21
}, {
name: 'B',
age: 23
}]
});
expect(exporter.getContent()).toBe('Name,Age\r\nA,21\r\nB,23\r\n');
});
test('test2', () => {
let exporter = new Exporter({
columns: [{
title: 'name',
}, {
title: 'age',
}],
data: [{
name: 'A',
age: 21
}, {
name: 'B',
age: 23
}]
});
expect(exporter.getContent()).toBe('name,age\r\nA,21\r\nB,23\r\n');
});
test('test3', () => {
let exporter = new Exporter({
columns: [{
title: 'Name',
key: 'name'
}, {
title: 'Age',
key: 'age',
formatter(age) {
return age + 10;
}
}],
data: [{
name: 'A',
age: 21
}, {
name: 'B',
age: 23
}]
});
expect(exporter.getContent()).toBe('Name,Age\r\nA,31\r\nB,33\r\n');
});
test('test4', () => {
let exporter = new Exporter({
columns: [{
title: 'Name',
}, {
title: 'Age'
}],
data: [
['A', 21],
['B', 23]
]
});
expect(exporter.getContent()).toBe('Name,Age\r\nA,21\r\nB,23\r\n');
});
test('test5', () => {
let exporter = new Exporter({
columns: [{
title: 'Name',
}, {
title: 'Age',
formatter(age) {
return age + 10;
}
}],
data: [
['A', 21],
['B', 23]
]
});
expect(exporter.getContent()).toBe('Name,Age\r\nA,31\r\nB,33\r\n');
});
test('test6', () => {
let exporter = new Exporter({
columns: ['Name', 'Age'],
data: [
['A', 21],
['B', 23]
]
});
expect(exporter.getContent()).toBe('Name,Age\r\nA,21\r\nB,23\r\n');
});
test('test7', () => {
let exporter = new Exporter({
columns: ['Name', 'Age'],
data: [
['姓名1', 21],
['姓名2', 23]
]
});
expect(exporter.getContent()).toBe('Name,Age\r\n姓名1,21\r\n姓名2,23\r\n');
});