table 3.8.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -16
- package/dist/alignString.js +19 -842
- package/dist/alignTableData.js +4 -226
- package/dist/calculateCellHeight.js +6 -343
- package/dist/calculateCellWidthIndex.js +2 -112
- package/dist/calculateMaximumColumnWidthIndex.js +5 -299
- package/dist/calculateRowHeightIndex.js +8 -333
- package/dist/createStream.js +19 -814
- package/dist/drawBorder.js +11 -292
- package/dist/drawRow.js +1 -69
- package/dist/drawTable.js +7 -474
- package/dist/getBorderCharacters.js +1 -315
- package/dist/index.js +4 -28
- package/dist/makeConfig.js +15 -544
- package/dist/makeStreamConfig.js +13 -587
- package/dist/mapDataUsingRowHeightIndex.js +9 -349
- package/dist/padTableData.js +5 -166
- package/dist/schemas/config.json +2 -2
- package/dist/schemas/streamConfig.json +2 -2
- package/dist/stringifyTableData.js +4 -116
- package/dist/table.js +5 -203
- package/dist/truncateTableData.js +3 -147
- package/dist/validateConfig.js +20 -23
- package/dist/validateStreamConfig.js +17 -19
- package/dist/validateTableData.js +11 -528
- package/dist/wrapString.js +3 -135
- package/dist/wrapWord.js +4 -257
- package/package.json +27 -24
- package/test/README/usage/basic.js +0 -25
- package/test/README/usage/cell_content_alignment.js +0 -45
- package/test/README/usage/column_width.js +0 -33
- package/test/README/usage/custom_border.js +0 -50
- package/test/README/usage/draw_horizontal_line.js +0 -41
- package/test/README/usage/expectTable.js +0 -13
- package/test/README/usage/moon_mission.js +0 -67
- package/test/README/usage/padding_cell_content.js +0 -39
- package/test/README/usage/predefined_border_templates.js +0 -91
- package/test/README/usage/streaming.js +0 -56
- package/test/README/usage/text_truncating.js +0 -32
- package/test/README/usage/text_wrapping.js +0 -67
- package/test/alignString.js +0 -102
- package/test/calculateCellHeight.js +0 -44
- package/test/calculateCellWidthIndex.js +0 -20
- package/test/calculateMaximumColumnWidthIndex.js +0 -59
- package/test/calculateRowHeightIndex.js +0 -78
- package/test/config.js +0 -43
- package/test/configSamples.js +0 -153
- package/test/createStream.js +0 -41
- package/test/drawBorder.js +0 -71
- package/test/makeConfig.js +0 -75
- package/test/mapDataUsingRowHeightIndex.js +0 -119
- package/test/streamConfig.js +0 -43
- package/test/streamConfigSamples.js +0 -151
- package/test/validateTableData.js +0 -65
- package/test/wrapString.js +0 -45
- package/test/wrapWord.js +0 -32
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-nested-callbacks */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
expect
|
|
5
|
-
} from 'chai';
|
|
6
|
-
import validateTableData from './../src/validateTableData';
|
|
7
|
-
|
|
8
|
-
describe('validateTableData', () => {
|
|
9
|
-
context('table does not have a row', () => {
|
|
10
|
-
it('throws an error', () => {
|
|
11
|
-
expect(() => {
|
|
12
|
-
validateTableData([]);
|
|
13
|
-
}).to.throw(Error, 'Table must define at least one row.');
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
context('table does not have a column', () => {
|
|
18
|
-
it('throws an error', () => {
|
|
19
|
-
expect(() => {
|
|
20
|
-
validateTableData([[]]);
|
|
21
|
-
}).to.throw(Error, 'Table must define at least one column.');
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
context('row data is not an array', () => {
|
|
26
|
-
it('throws an error', () => {
|
|
27
|
-
expect(() => {
|
|
28
|
-
validateTableData({});
|
|
29
|
-
}).to.throw(Error, 'Table data must be an array.');
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
context('column data is not an array', () => {
|
|
34
|
-
it('throws an error', () => {
|
|
35
|
-
expect(() => {
|
|
36
|
-
validateTableData([{}]);
|
|
37
|
-
}).to.throw(Error, 'Table row data must be an array.');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
context('cell data contains a control character', () => {
|
|
42
|
-
it('throws an error', () => {
|
|
43
|
-
expect(() => {
|
|
44
|
-
validateTableData([
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
String.fromCodePoint(0x01)
|
|
48
|
-
]
|
|
49
|
-
]
|
|
50
|
-
]);
|
|
51
|
-
}).to.throw(Error, 'Table data must not contain control characters.');
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
context('rows have inconsistent number of cells', () => {
|
|
56
|
-
it('throws an error', () => {
|
|
57
|
-
expect(() => {
|
|
58
|
-
validateTableData([
|
|
59
|
-
['a', 'b', 'c'],
|
|
60
|
-
['a', 'b']
|
|
61
|
-
]);
|
|
62
|
-
}).to.throw(Error, 'Table must have a consistent number of cells.');
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
package/test/wrapString.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-nested-callbacks */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
expect
|
|
5
|
-
} from 'chai';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import wrapString from './../src/wrapString';
|
|
8
|
-
|
|
9
|
-
describe('wrapString', () => {
|
|
10
|
-
context('subject is a plain text string', () => {
|
|
11
|
-
context('subject is lesser than the chunk size', () => {
|
|
12
|
-
it('returns subject in a single chunk', () => {
|
|
13
|
-
expect(wrapString('aaa', 3)).to.deep.equal(['aaa']);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
context('subject is larger than the chunk size', () => {
|
|
17
|
-
it('returns subject sliced into multiple chunks', () => {
|
|
18
|
-
expect(wrapString('aaabbbc', 3)).to.deep.equal(['aaa', 'bbb', 'c']);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
context('a chunk starts with a space', () => {
|
|
22
|
-
it('adjusts chunks to offset the space', () => {
|
|
23
|
-
expect(wrapString('aaa bbb ccc', 3)).to.deep.equal(['aaa', 'bbb', 'ccc']);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
context('subject string contains ANSI escape codes', () => {
|
|
28
|
-
describe('subject is lesser than the chunk size', () => {
|
|
29
|
-
it('returns subject in a single chunk', () => {
|
|
30
|
-
expect(wrapString(chalk.red('aaa'), 3)).to.deep.equal([
|
|
31
|
-
'\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31maaa\u001b[39m'
|
|
32
|
-
]);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe('subject is larger than the chunk size', () => {
|
|
36
|
-
it('returns subject sliced into multiple chunks', () => {
|
|
37
|
-
expect(wrapString(chalk.red('aaabbbc'), 3)).to.deep.equal([
|
|
38
|
-
'\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31maaa\u001b[39m',
|
|
39
|
-
'\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31mbbb\u001b[39m',
|
|
40
|
-
'\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31mc\u001b[39m'
|
|
41
|
-
]);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
package/test/wrapWord.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
expect
|
|
3
|
-
} from 'chai';
|
|
4
|
-
import wrapWord from './../src/wrapWord';
|
|
5
|
-
|
|
6
|
-
describe('wrapWord', () => {
|
|
7
|
-
it('wraps a string at a nearest whitespace', () => {
|
|
8
|
-
expect(wrapWord('aaa bbb', 5)).to.deep.equal(['aaa', 'bbb']);
|
|
9
|
-
expect(wrapWord('a a a bbb', 5)).to.deep.equal(['a a a', 'bbb']);
|
|
10
|
-
});
|
|
11
|
-
context('a single word is longer than chunk size', () => {
|
|
12
|
-
it('cuts the word', () => {
|
|
13
|
-
expect(wrapWord('aaaaa', 2)).to.deep.equal(['aa', 'aa', 'a']);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
context('a long word with a special character', () => {
|
|
17
|
-
it('cuts the word at the special character', () => {
|
|
18
|
-
expect(wrapWord('aaa\\bbb', 5)).to.deep.equal(['aaa\\', 'bbb']);
|
|
19
|
-
expect(wrapWord('aaa/bbb', 5)).to.deep.equal(['aaa/', 'bbb']);
|
|
20
|
-
expect(wrapWord('aaa_bbb', 5)).to.deep.equal(['aaa_', 'bbb']);
|
|
21
|
-
expect(wrapWord('aaa-bbb', 5)).to.deep.equal(['aaa-', 'bbb']);
|
|
22
|
-
expect(wrapWord('aaa.bbb', 5)).to.deep.equal(['aaa.', 'bbb']);
|
|
23
|
-
expect(wrapWord('aaa,bbb', 5)).to.deep.equal(['aaa,', 'bbb']);
|
|
24
|
-
expect(wrapWord('aaa;bbb', 5)).to.deep.equal(['aaa;', 'bbb']);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
context('a special character after the length of a container', () => {
|
|
28
|
-
it('does not include special character', () => {
|
|
29
|
-
expect(wrapWord('aa-bbbbb-cccc', 5)).to.deep.equal(['aa-', 'bbbbb', '-cccc']);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|