forked from plotly/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable_clipboard_helper_test.ts
49 lines (44 loc) · 1.83 KB
/
table_clipboard_helper_test.ts
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
import {expect} from 'chai';
import TableClipboardHelper from 'dash-table/utils/TableClipboardHelper';
describe('table clipboard helper tests', () => {
it('test parse basic', () => {
const res = TableClipboardHelper.parse('abc\tefg\n123\t456');
expect(res.length).to.equal(2);
expect(res[0].length).to.equal(2);
expect(res[1].length).to.equal(2);
expect(res[0][0]).to.equal('abc');
expect(res[0][1]).to.equal('efg');
expect(res[1][0]).to.equal('123');
expect(res[1][1]).to.equal('456');
});
it('test parse with double quotes', () => {
const res = TableClipboardHelper.parse('a""bc\tefg\n123\t456');
expect(res.length).to.equal(2);
expect(res[0].length).to.equal(2);
expect(res[1].length).to.equal(2);
expect(res[0][0]).to.equal('a""bc');
expect(res[0][1]).to.equal('efg');
expect(res[1][0]).to.equal('123');
expect(res[1][1]).to.equal('456');
});
it('test with multiline', () => {
const res = TableClipboardHelper.parse('"a\nb\nc"\tefg\n123\t456');
expect(res.length).to.equal(2);
expect(res[0].length).to.equal(2);
expect(res[1].length).to.equal(2);
expect(res[0][0]).to.equal('a\nb\nc');
expect(res[0][1]).to.equal('efg');
expect(res[1][0]).to.equal('123');
expect(res[1][1]).to.equal('456');
});
it('test with multiline and double quotes', () => {
const res = TableClipboardHelper.parse('"a\nb""c"\te""fg\n123\t456');
expect(res.length).to.equal(2);
expect(res[0].length).to.equal(2);
expect(res[1].length).to.equal(2);
expect(res[0][0]).to.equal('a\nb"c');
expect(res[0][1]).to.equal('e""fg');
expect(res[1][0]).to.equal('123');
expect(res[1][1]).to.equal('456');
});
});