437b8059
Sergio Crisostomo
Added Table to CS...
|
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
|
import { createVue, destroyVM } from '../util';
import { csvA, csvB } from './assets/table/csvData.js';
const cleanCSV = (str) => str.split('\n').map(s => s.trim()).filter(Boolean).join('\n');
describe('Table.vue', () => {
let vm;
afterEach(() => {
destroyVM(vm);
});
describe('CSV export', () => {
it('should export simple data to CSV - test A', done => {
vm = createVue({
template: '<div><Table :columns="columns" :data="data" ref="tableA" /></div>',
data() {
return csvA;
},
mounted() {
this.$refs.tableA.exportCsv({callback: data => {
expect(cleanCSV(data)).to.equal(cleanCSV(this.expected));
expect(cleanCSV(data).length > 0).to.equal(true);
done();
}});
}
});
});
it('should export data with commas and line breaks to CSV - test B', done => {
vm = createVue({
template: '<div><Table :columns="columns" :data="data" ref="tableB" /></div>',
data() {
return csvB;
},
mounted() {
this.$refs.tableB.exportCsv({separator: ';', quoted: true, callback: data => {
expect(cleanCSV(data)).to.equal(cleanCSV(this.expected));
expect(cleanCSV(data).length > 0).to.equal(true);
done();
}});
}
});
});
});
});
|