table 6.7.4 → 6.7.5
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/package.json +4 -4
- package/dist/test/README/api/getBorderCharacters.d.ts +0 -1
- package/dist/test/README/api/getBorderCharacters.js +0 -76
- package/dist/test/README/api/stream/streaming.d.ts +0 -1
- package/dist/test/README/api/stream/streaming.js +0 -41
- package/dist/test/README/api/table/border.d.ts +0 -1
- package/dist/test/README/api/table/border.js +0 -45
- package/dist/test/README/api/table/column/alignment.d.ts +0 -1
- package/dist/test/README/api/table/column/alignment.js +0 -34
- package/dist/test/README/api/table/column/padding.d.ts +0 -1
- package/dist/test/README/api/table/column/padding.js +0 -36
- package/dist/test/README/api/table/column/truncate.d.ts +0 -1
- package/dist/test/README/api/table/column/truncate.js +0 -29
- package/dist/test/README/api/table/column/verticalAlignment.d.ts +0 -1
- package/dist/test/README/api/table/column/verticalAlignment.js +0 -28
- package/dist/test/README/api/table/column/width.d.ts +0 -1
- package/dist/test/README/api/table/column/width.js +0 -30
- package/dist/test/README/api/table/column/wrapWord.d.ts +0 -1
- package/dist/test/README/api/table/column/wrapWord.js +0 -51
- package/dist/test/README/api/table/drawHorizontalLine.d.ts +0 -1
- package/dist/test/README/api/table/drawHorizontalLine.js +0 -33
- package/dist/test/README/api/table/drawVerticalLine.d.ts +0 -1
- package/dist/test/README/api/table/drawVerticalLine.js +0 -35
- package/dist/test/README/api/table/header.d.ts +0 -1
- package/dist/test/README/api/table/header.js +0 -35
- package/dist/test/README/api/table/singleLine.d.ts +0 -1
- package/dist/test/README/api/table/singleLine.js +0 -35
- package/dist/test/README/demo.d.ts +0 -1
- package/dist/test/README/demo.js +0 -71
- package/dist/test/README/usage.d.ts +0 -1
- package/dist/test/README/usage.js +0 -24
- package/dist/test/alignString.d.ts +0 -1
- package/dist/test/alignString.js +0 -124
- package/dist/test/alignTableData.d.ts +0 -1
- package/dist/test/alignTableData.js +0 -63
- package/dist/test/calculateCellHeight.d.ts +0 -1
- package/dist/test/calculateCellHeight.js +0 -28
- package/dist/test/calculateCellWidths.d.ts +0 -1
- package/dist/test/calculateCellWidths.js +0 -27
- package/dist/test/calculateColumnWidths.d.ts +0 -1
- package/dist/test/calculateColumnWidths.js +0 -54
- package/dist/test/calculateRowHeights.d.ts +0 -1
- package/dist/test/calculateRowHeights.js +0 -61
- package/dist/test/createStream.d.ts +0 -1
- package/dist/test/createStream.js +0 -122
- package/dist/test/drawBorder.d.ts +0 -1
- package/dist/test/drawBorder.js +0 -139
- package/dist/test/drawHeader.d.ts +0 -1
- package/dist/test/drawHeader.js +0 -172
- package/dist/test/drawRow.d.ts +0 -1
- package/dist/test/drawRow.js +0 -54
- package/dist/test/getBorderCharacters.d.ts +0 -1
- package/dist/test/getBorderCharacters.js +0 -104
- package/dist/test/makeConfig.d.ts +0 -1
- package/dist/test/makeConfig.js +0 -152
- package/dist/test/makeStreamConfig.d.ts +0 -1
- package/dist/test/makeStreamConfig.js +0 -106
- package/dist/test/mapDataUsingRowHeights.d.ts +0 -1
- package/dist/test/mapDataUsingRowHeights.js +0 -150
- package/dist/test/padTableData.d.ts +0 -1
- package/dist/test/padTableData.js +0 -62
- package/dist/test/streamConfigSamples.d.ts +0 -6
- package/dist/test/streamConfigSamples.js +0 -287
- package/dist/test/stringifyTableData.d.ts +0 -1
- package/dist/test/stringifyTableData.js +0 -17
- package/dist/test/table.d.ts +0 -1
- package/dist/test/table.js +0 -171
- package/dist/test/tableConfigSamples.d.ts +0 -5
- package/dist/test/tableConfigSamples.js +0 -202
- package/dist/test/truncateTableData.d.ts +0 -1
- package/dist/test/truncateTableData.js +0 -92
- package/dist/test/utils.d.ts +0 -7
- package/dist/test/utils.js +0 -23
- package/dist/test/validateConfig.d.ts +0 -1
- package/dist/test/validateConfig.js +0 -36
- package/dist/test/validateStreamConfig.d.ts +0 -1
- package/dist/test/validateStreamConfig.js +0 -39
- package/dist/test/validateTableConfig.d.ts +0 -1
- package/dist/test/validateTableConfig.js +0 -35
- package/dist/test/validateTableData.d.ts +0 -1
- package/dist/test/validateTableData.js +0 -106
- package/dist/test/wrapCell.d.ts +0 -1
- package/dist/test/wrapCell.js +0 -114
- package/dist/test/wrapString.d.ts +0 -1
- package/dist/test/wrapString.js +0 -45
- package/dist/test/wrapWord.d.ts +0 -1
- package/dist/test/wrapWord.js +0 -94
package/dist/test/table.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable max-nested-callbacks */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const chai_1 = require("chai");
|
|
5
|
-
const src_1 = require("../src");
|
|
6
|
-
const utils_1 = require("./utils");
|
|
7
|
-
const data = [
|
|
8
|
-
['Lorem ipsum', 'dolor sit'],
|
|
9
|
-
['amet', 'consectetur'],
|
|
10
|
-
['adipiscing', 'elit'],
|
|
11
|
-
];
|
|
12
|
-
const basicConfig = {
|
|
13
|
-
columnDefault: {
|
|
14
|
-
width: 5,
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
describe('drawTable', () => {
|
|
18
|
-
describe('drawHorizontalLine', () => {
|
|
19
|
-
context('only draw top and bottom borders', () => {
|
|
20
|
-
it('draws proper borders', () => {
|
|
21
|
-
const config = {
|
|
22
|
-
...basicConfig,
|
|
23
|
-
drawHorizontalLine: (index, size) => {
|
|
24
|
-
return index === 0 || index === size;
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
(0, chai_1.expect)((0, src_1.table)(data, config)).to.be.deep.equal(`
|
|
28
|
-
╔═══════╤═══════╗
|
|
29
|
-
║ Lorem │ dolor ║
|
|
30
|
-
║ ipsum │ sit ║
|
|
31
|
-
║ amet │ conse ║
|
|
32
|
-
║ │ ctetu ║
|
|
33
|
-
║ │ r ║
|
|
34
|
-
║ adipi │ elit ║
|
|
35
|
-
║ scing │ ║
|
|
36
|
-
╚═══════╧═══════╝
|
|
37
|
-
`.trimLeft());
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
context('only draw inner borders', () => {
|
|
41
|
-
it('draws proper borders', () => {
|
|
42
|
-
const config = {
|
|
43
|
-
...basicConfig,
|
|
44
|
-
drawHorizontalLine: (index, size) => {
|
|
45
|
-
return index > 0 && index < size;
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
(0, chai_1.expect)((0, src_1.table)(data, config)).to.be.deep.equal(`
|
|
49
|
-
║ Lorem │ dolor ║
|
|
50
|
-
║ ipsum │ sit ║
|
|
51
|
-
╟───────┼───────╢
|
|
52
|
-
║ amet │ conse ║
|
|
53
|
-
║ │ ctetu ║
|
|
54
|
-
║ │ r ║
|
|
55
|
-
╟───────┼───────╢
|
|
56
|
-
║ adipi │ elit ║
|
|
57
|
-
║ scing │ ║
|
|
58
|
-
`.trimLeft());
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
context('only draw top and next-to-last borders', () => {
|
|
62
|
-
it('draws proper borders', () => {
|
|
63
|
-
const config = {
|
|
64
|
-
...basicConfig,
|
|
65
|
-
drawHorizontalLine: (index, size) => {
|
|
66
|
-
return index === 0 || index === size - 1;
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
(0, chai_1.expect)((0, src_1.table)(data, config)).to.be.deep.equal(`
|
|
70
|
-
╔═══════╤═══════╗
|
|
71
|
-
║ Lorem │ dolor ║
|
|
72
|
-
║ ipsum │ sit ║
|
|
73
|
-
║ amet │ conse ║
|
|
74
|
-
║ │ ctetu ║
|
|
75
|
-
║ │ r ║
|
|
76
|
-
╟───────┼───────╢
|
|
77
|
-
║ adipi │ elit ║
|
|
78
|
-
║ scing │ ║
|
|
79
|
-
`.trimLeft());
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
context('header', () => {
|
|
84
|
-
it('draw properly', () => {
|
|
85
|
-
const config = {
|
|
86
|
-
...basicConfig,
|
|
87
|
-
header: {
|
|
88
|
-
content: 'This is the long long header',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
(0, chai_1.expect)((0, src_1.table)(data, config)).to.be.deep.equal(`
|
|
92
|
-
╔═══════════════╗
|
|
93
|
-
║ This is the l ║
|
|
94
|
-
║ ong long head ║
|
|
95
|
-
║ er ║
|
|
96
|
-
╟───────┬───────╢
|
|
97
|
-
║ Lorem │ dolor ║
|
|
98
|
-
║ ipsum │ sit ║
|
|
99
|
-
╟───────┼───────╢
|
|
100
|
-
║ amet │ conse ║
|
|
101
|
-
║ │ ctetu ║
|
|
102
|
-
║ │ r ║
|
|
103
|
-
╟───────┼───────╢
|
|
104
|
-
║ adipi │ elit ║
|
|
105
|
-
║ scing │ ║
|
|
106
|
-
╚═══════╧═══════╝
|
|
107
|
-
`.trimLeft());
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
context('vertical alignment', () => {
|
|
111
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
112
|
-
const data = [
|
|
113
|
-
['Lorem ipsum dolor sit amet, consectetur adipiscing elit',
|
|
114
|
-
'Phasellus pulvinar nibh sed',
|
|
115
|
-
'Phasellus pulvinar nibh sed',
|
|
116
|
-
'Phasellus pulvinar nibh sed'],
|
|
117
|
-
];
|
|
118
|
-
it('works properly', () => {
|
|
119
|
-
const result = (0, src_1.table)(data, {
|
|
120
|
-
columnDefault: {
|
|
121
|
-
width: 10,
|
|
122
|
-
},
|
|
123
|
-
columns: [
|
|
124
|
-
{},
|
|
125
|
-
{ verticalAlignment: 'top' },
|
|
126
|
-
{ verticalAlignment: 'middle' },
|
|
127
|
-
{ verticalAlignment: 'bottom' }
|
|
128
|
-
],
|
|
129
|
-
});
|
|
130
|
-
(0, utils_1.expectTable)(result, `
|
|
131
|
-
╔════════════╤════════════╤════════════╤════════════╗
|
|
132
|
-
║ Lorem ipsu │ Phasellus │ │ ║
|
|
133
|
-
║ m dolor si │ pulvinar n │ Phasellus │ ║
|
|
134
|
-
║ t amet, co │ ibh sed │ pulvinar n │ ║
|
|
135
|
-
║ nsectetur │ │ ibh sed │ Phasellus ║
|
|
136
|
-
║ adipiscing │ │ │ pulvinar n ║
|
|
137
|
-
║ elit │ │ │ ibh sed ║
|
|
138
|
-
╚════════════╧════════════╧════════════╧════════════╝`);
|
|
139
|
-
});
|
|
140
|
-
it('works with horizontal alignment', () => {
|
|
141
|
-
const result = (0, src_1.table)(data, {
|
|
142
|
-
columnDefault: {
|
|
143
|
-
width: 8,
|
|
144
|
-
wrapWord: true,
|
|
145
|
-
},
|
|
146
|
-
columns: [
|
|
147
|
-
{},
|
|
148
|
-
{ alignment: 'center',
|
|
149
|
-
verticalAlignment: 'top' },
|
|
150
|
-
{ alignment: 'right',
|
|
151
|
-
verticalAlignment: 'middle' },
|
|
152
|
-
{ alignment: 'left',
|
|
153
|
-
verticalAlignment: 'bottom' }
|
|
154
|
-
],
|
|
155
|
-
});
|
|
156
|
-
(0, utils_1.expectTable)(result, `
|
|
157
|
-
╔══════════╤══════════╤══════════╤══════════╗
|
|
158
|
-
║ Lorem │ Phasellu │ │ ║
|
|
159
|
-
║ ipsum │ s │ │ ║
|
|
160
|
-
║ dolor │ pulvinar │ Phasellu │ ║
|
|
161
|
-
║ sit │ nibh sed │ s │ ║
|
|
162
|
-
║ amet, │ │ pulvinar │ ║
|
|
163
|
-
║ consecte │ │ nibh sed │ Phasellu ║
|
|
164
|
-
║ tur │ │ │ s ║
|
|
165
|
-
║ adipisci │ │ │ pulvinar ║
|
|
166
|
-
║ ng elit │ │ │ nibh sed ║
|
|
167
|
-
╚══════════╧══════════╧══════════╧══════════╝`);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
//# sourceMappingURL=table.js.map
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tableConfigSamples = void 0;
|
|
4
|
-
exports.tableConfigSamples = {
|
|
5
|
-
invalid: [
|
|
6
|
-
{ border: 1 },
|
|
7
|
-
{ border: { unknown: '-' } },
|
|
8
|
-
{ border: { topBody: 1 } },
|
|
9
|
-
{ border: { topJoin: 1 } },
|
|
10
|
-
{ border: { topLeft: 1 } },
|
|
11
|
-
{ border: { topRight: 1 } },
|
|
12
|
-
{ border: { bottomBody: 1 } },
|
|
13
|
-
{ border: { bottomJoin: 1 } },
|
|
14
|
-
{ border: { bottomLeft: 1 } },
|
|
15
|
-
{ border: { bottomRight: 1 } },
|
|
16
|
-
{ border: { bodyLeft: 1 } },
|
|
17
|
-
{ border: { bodyRight: 1 } },
|
|
18
|
-
{ border: { bodyJoin: 1 } },
|
|
19
|
-
{ border: { joinBody: 1 } },
|
|
20
|
-
{ border: { joinLeft: 1 } },
|
|
21
|
-
{ border: { joinRight: 1 } },
|
|
22
|
-
{ border: { joinJoin: 1 } },
|
|
23
|
-
{ columns: 1 },
|
|
24
|
-
{ columns: { a: { width: 5 } } },
|
|
25
|
-
{ columns: { 1: 1 } },
|
|
26
|
-
{ columns: { 1: { unknown: 1 } } },
|
|
27
|
-
{ columns: { 1: { alignment: 1 } } },
|
|
28
|
-
{ columns: { 1: { alignment: '1' } } },
|
|
29
|
-
{ columns: { 0: { alignment: 'middle' } } },
|
|
30
|
-
{ columns: { 1: { verticalAlignment: 1 } } },
|
|
31
|
-
{ columns: { 1: { verticalAlignment: '1' } } },
|
|
32
|
-
{ columns: { 0: { verticalAlignment: 'center' } } },
|
|
33
|
-
{ columns: { 1: { width: 0 } } },
|
|
34
|
-
{ columns: { 1: { width: 1.5 } } },
|
|
35
|
-
{ columns: { 1: { width: '5' } } },
|
|
36
|
-
{ columns: { 1: { wrapWord: 1 } } },
|
|
37
|
-
{ columns: { 1: { wrapWord: 'true' } } },
|
|
38
|
-
{ columns: { 1: { truncate: '1' } } },
|
|
39
|
-
{ columns: { 1: { paddingLeft: '1' } } },
|
|
40
|
-
{ columns: { 1: { paddingRight: '1' } } },
|
|
41
|
-
{ columns: [1] },
|
|
42
|
-
{ columns: [''] },
|
|
43
|
-
{ columns: [{ unknown: 1 }] },
|
|
44
|
-
{ columnDefault: 1 },
|
|
45
|
-
{ columnDefault: { unknown: 1 } },
|
|
46
|
-
{ columnDefault: { alignment: 1 } },
|
|
47
|
-
{ columnDefault: { alignment: '1' } },
|
|
48
|
-
{ columnDefault: { alignment: 'middle' } },
|
|
49
|
-
{ columnDefault: { verticalAlignment: 1 } },
|
|
50
|
-
{ columnDefault: { verticalAlignment: '1' } },
|
|
51
|
-
{ columnDefault: { verticalAlignment: 'center' } },
|
|
52
|
-
{ columnDefault: { width: 0 } },
|
|
53
|
-
{ columnDefault: { width: 1.5 } },
|
|
54
|
-
{ columnDefault: { width: '5' } },
|
|
55
|
-
{ columnDefault: { wrapWord: 1 } },
|
|
56
|
-
{ columnDefault: { wrapWord: 'true' } },
|
|
57
|
-
{ columnDefault: { truncate: '1' } },
|
|
58
|
-
{ columnDefault: { paddingLeft: '1' } },
|
|
59
|
-
{ columnDefault: { paddingRight: '1' } },
|
|
60
|
-
{ drawHorizontalLine: 1 },
|
|
61
|
-
{ unknown: 1 },
|
|
62
|
-
{ header: 'a' },
|
|
63
|
-
{ header: { unknown: 'x' } },
|
|
64
|
-
{ header: { content: 1 } },
|
|
65
|
-
{ header: { content: 'x',
|
|
66
|
-
width: 10 } },
|
|
67
|
-
],
|
|
68
|
-
valid: [
|
|
69
|
-
{},
|
|
70
|
-
{
|
|
71
|
-
columns: {
|
|
72
|
-
0: {
|
|
73
|
-
alignment: 'left',
|
|
74
|
-
verticalAlignment: 'bottom',
|
|
75
|
-
width: 10,
|
|
76
|
-
},
|
|
77
|
-
1: {
|
|
78
|
-
alignment: 'center',
|
|
79
|
-
verticalAlignment: 'middle',
|
|
80
|
-
width: 10,
|
|
81
|
-
},
|
|
82
|
-
2: {
|
|
83
|
-
alignment: 'right',
|
|
84
|
-
verticalAlignment: 'top',
|
|
85
|
-
width: 10,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
border: {
|
|
91
|
-
bodyJoin: '│',
|
|
92
|
-
bodyLeft: '│',
|
|
93
|
-
bodyRight: '│',
|
|
94
|
-
bottomBody: '─',
|
|
95
|
-
bottomJoin: '┴',
|
|
96
|
-
bottomLeft: '└',
|
|
97
|
-
bottomRight: '┘',
|
|
98
|
-
joinBody: '─',
|
|
99
|
-
joinJoin: '┼',
|
|
100
|
-
joinLeft: '├',
|
|
101
|
-
joinRight: '┤',
|
|
102
|
-
topBody: '─',
|
|
103
|
-
topJoin: '┬',
|
|
104
|
-
topLeft: '┌',
|
|
105
|
-
topRight: '┐',
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
columns: {
|
|
110
|
-
0: {
|
|
111
|
-
paddingLeft: 3,
|
|
112
|
-
},
|
|
113
|
-
1: {
|
|
114
|
-
paddingRight: 3,
|
|
115
|
-
width: 2,
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
border: {},
|
|
121
|
-
columnDefault: {
|
|
122
|
-
paddingLeft: 0,
|
|
123
|
-
paddingRight: 1,
|
|
124
|
-
},
|
|
125
|
-
drawHorizontalLine: () => {
|
|
126
|
-
return false;
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
columnDefault: {
|
|
131
|
-
width: 50,
|
|
132
|
-
},
|
|
133
|
-
columns: {
|
|
134
|
-
0: {
|
|
135
|
-
alignment: 'right',
|
|
136
|
-
width: 10,
|
|
137
|
-
},
|
|
138
|
-
1: {
|
|
139
|
-
alignment: 'center',
|
|
140
|
-
},
|
|
141
|
-
2: {
|
|
142
|
-
width: 10,
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
{ columns: { 0: { alignment: 'left' } } },
|
|
147
|
-
{ columns: { 1: { alignment: 'right' } } },
|
|
148
|
-
{ columns: { 2: { alignment: 'center' } } },
|
|
149
|
-
{ columns: { 3: { alignment: 'justify' } } },
|
|
150
|
-
{ columns: { 0: { verticalAlignment: 'top' } } },
|
|
151
|
-
{ columns: { 1: { verticalAlignment: 'middle' } } },
|
|
152
|
-
{ columns: { 2: { verticalAlignment: 'bottom' } } },
|
|
153
|
-
{ border: { topBody: '-' } },
|
|
154
|
-
{ border: { topJoin: '-' } },
|
|
155
|
-
{ border: { topLeft: '-' } },
|
|
156
|
-
{ border: { topRight: '-' } },
|
|
157
|
-
{ border: { bottomBody: '-' } },
|
|
158
|
-
{ border: { bottomJoin: '-' } },
|
|
159
|
-
{ border: { bottomLeft: '-' } },
|
|
160
|
-
{ border: { bottomRight: '-' } },
|
|
161
|
-
{ border: { bodyLeft: '-' } },
|
|
162
|
-
{ border: { bodyRight: '-' } },
|
|
163
|
-
{ border: { bodyJoin: '-' } },
|
|
164
|
-
{ border: { joinBody: '-' } },
|
|
165
|
-
{ border: { joinLeft: '-' } },
|
|
166
|
-
{ border: { joinRight: '-' } },
|
|
167
|
-
{ border: { joinJoin: '-' } },
|
|
168
|
-
{ columns: { 1: { alignment: 'left' } } },
|
|
169
|
-
{ columns: { 1: { width: 1 } } },
|
|
170
|
-
{ columns: { 1: { width: 5 } } },
|
|
171
|
-
{ columns: { 1: { wrapWord: true } } },
|
|
172
|
-
{ columns: { 1: { wrapWord: false } } },
|
|
173
|
-
{ columns: { 1: { truncate: 1 } } },
|
|
174
|
-
{ columns: { 1: { paddingLeft: 1 } } },
|
|
175
|
-
{ columns: { 1: { paddingRight: 1 } } },
|
|
176
|
-
{ columns: [] },
|
|
177
|
-
{ columns: [{ width: 5 }] },
|
|
178
|
-
{ columns: [{ wrapWord: true }, { truncate: 1 }] },
|
|
179
|
-
{ columns: [{ paddingLeft: 1 }, { paddingRight: 1 }, { alignment: 'right' }] },
|
|
180
|
-
{ columnDefault: { alignment: 'left' } },
|
|
181
|
-
{ columnDefault: { width: 1 } },
|
|
182
|
-
{ columnDefault: { width: 5 } },
|
|
183
|
-
{ columnDefault: { wrapWord: true } },
|
|
184
|
-
{ columnDefault: { wrapWord: false } },
|
|
185
|
-
{ columnDefault: { truncate: 1 } },
|
|
186
|
-
{ columnDefault: { paddingLeft: 1 } },
|
|
187
|
-
{ columnDefault: { paddingRight: 1 } },
|
|
188
|
-
{ drawHorizontalLine: () => {
|
|
189
|
-
return false;
|
|
190
|
-
} },
|
|
191
|
-
{ header: { content: '' } },
|
|
192
|
-
{ header: {
|
|
193
|
-
alignment: 'justify',
|
|
194
|
-
content: 'a',
|
|
195
|
-
paddingLeft: 5,
|
|
196
|
-
paddingRight: 8,
|
|
197
|
-
truncate: 3,
|
|
198
|
-
wrapWord: true,
|
|
199
|
-
} },
|
|
200
|
-
],
|
|
201
|
-
};
|
|
202
|
-
//# sourceMappingURL=tableConfigSamples.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable max-nested-callbacks */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const chai_1 = require("chai");
|
|
5
|
-
const makeTableConfig_1 = require("../src/makeTableConfig");
|
|
6
|
-
const truncateTableData_1 = require("../src/truncateTableData");
|
|
7
|
-
describe('truncateTableData', () => {
|
|
8
|
-
context('when no given userConfig', () => {
|
|
9
|
-
it('not truncate at all', () => {
|
|
10
|
-
const rows = [['a'.repeat(100)]];
|
|
11
|
-
(0, chai_1.expect)((0, truncateTableData_1.truncateTableData)(rows, (0, makeTableConfig_1.makeTableConfig)(rows, undefined))).to.deep.equal([['a'.repeat(100)]]);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
context('when given truncate value in columnDefault', () => {
|
|
15
|
-
context('when no given column-specific truncate', () => {
|
|
16
|
-
it('uses the columnDefault value', () => {
|
|
17
|
-
const rows = [['a'.repeat(100)]];
|
|
18
|
-
(0, chai_1.expect)((0, truncateTableData_1.truncateTableData)(rows, (0, makeTableConfig_1.makeTableConfig)(rows, { columnDefault: {
|
|
19
|
-
truncate: 20,
|
|
20
|
-
} }))).to.deep.equal([['a'.repeat(19) + '…']]);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
context('when given column-specific truncate value', () => {
|
|
24
|
-
it('uses column-specific truncate value', () => {
|
|
25
|
-
const rows = [['a'.repeat(100)]];
|
|
26
|
-
(0, chai_1.expect)((0, truncateTableData_1.truncateTableData)(rows, (0, makeTableConfig_1.makeTableConfig)(rows, {
|
|
27
|
-
columnDefault: {
|
|
28
|
-
truncate: 20,
|
|
29
|
-
},
|
|
30
|
-
columns: {
|
|
31
|
-
0: {
|
|
32
|
-
truncate: 30,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
}))).to.deep.equal([['a'.repeat(29) + '…']]);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
context('when given multiple rows and columns', () => {
|
|
40
|
-
it('uses corresponding column-specific truncate values or fallback to the default truncate value', () => {
|
|
41
|
-
const rows = [['a'.repeat(100), 'b'.repeat(100)], ['c'.repeat(100), 'd'.repeat(100)]];
|
|
42
|
-
(0, chai_1.expect)((0, truncateTableData_1.truncateTableData)(rows, (0, makeTableConfig_1.makeTableConfig)(rows, {
|
|
43
|
-
columnDefault: {
|
|
44
|
-
truncate: 20,
|
|
45
|
-
},
|
|
46
|
-
columns: {
|
|
47
|
-
0: {
|
|
48
|
-
truncate: 30,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
}))).to.deep.equal([
|
|
52
|
-
['a'.repeat(29) + '…', 'b'.repeat(19) + '…'],
|
|
53
|
-
['c'.repeat(29) + '…', 'd'.repeat(19) + '…']
|
|
54
|
-
]);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
context('edge cases', () => {
|
|
58
|
-
context('truncate = 0', () => {
|
|
59
|
-
it('returns ellipsis only', () => {
|
|
60
|
-
const rows = [['a'.repeat(100)]];
|
|
61
|
-
(0, chai_1.expect)((0, truncateTableData_1.truncateTableData)(rows, (0, makeTableConfig_1.makeTableConfig)(rows, {
|
|
62
|
-
columns: { 0: { truncate: 0 } },
|
|
63
|
-
}))).to.deep.equal([['…']]);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
context('truncate = 1', () => {
|
|
67
|
-
it('returns ellipsis only', () => {
|
|
68
|
-
const rows = [['a'.repeat(100)]];
|
|
69
|
-
(0, chai_1.expect)((0, truncateTableData_1.truncateTableData)(rows, (0, makeTableConfig_1.makeTableConfig)(rows, {
|
|
70
|
-
columns: { 0: { truncate: 1 } },
|
|
71
|
-
}))).to.deep.equal([['…']]);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
context('truncate = 2', () => {
|
|
75
|
-
it('returns 2-length string with ellipsis', () => {
|
|
76
|
-
const rows = [['a'.repeat(100)]];
|
|
77
|
-
(0, chai_1.expect)((0, truncateTableData_1.truncateTableData)(rows, (0, makeTableConfig_1.makeTableConfig)(rows, {
|
|
78
|
-
columns: { 0: { truncate: 2 } },
|
|
79
|
-
}))).to.deep.equal([['a…']]);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
context('empty string', () => {
|
|
83
|
-
it('returns empty string', () => {
|
|
84
|
-
const rows = [['']];
|
|
85
|
-
(0, chai_1.expect)((0, truncateTableData_1.truncateTableData)(rows, (0, makeTableConfig_1.makeTableConfig)(rows, {
|
|
86
|
-
columns: { 0: { truncate: 100 } },
|
|
87
|
-
}))).to.deep.equal([['']]);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
//# sourceMappingURL=truncateTableData.js.map
|
package/dist/test/utils.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const openRed = "\u001B[31m";
|
|
2
|
-
export declare const closeRed = "\u001B[39m";
|
|
3
|
-
export declare const openBold = "\u001B[1m";
|
|
4
|
-
export declare const closeBold = "\u001B[22m";
|
|
5
|
-
export declare const stringToRed: (string: string) => string;
|
|
6
|
-
export declare const arrayToRed: (array: string[]) => string[];
|
|
7
|
-
export declare const expectTable: (result: string, expectedResult: string) => void;
|
package/dist/test/utils.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expectTable = exports.arrayToRed = exports.stringToRed = exports.closeBold = exports.openBold = exports.closeRed = exports.openRed = void 0;
|
|
4
|
-
const chai_1 = require("chai");
|
|
5
|
-
exports.openRed = '\u001b[31m';
|
|
6
|
-
exports.closeRed = '\u001b[39m';
|
|
7
|
-
exports.openBold = '\u001b[1m';
|
|
8
|
-
exports.closeBold = '\u001b[22m';
|
|
9
|
-
const stringToRed = (string) => {
|
|
10
|
-
return exports.openRed + string + exports.closeRed;
|
|
11
|
-
};
|
|
12
|
-
exports.stringToRed = stringToRed;
|
|
13
|
-
const arrayToRed = (array) => {
|
|
14
|
-
return array.map((string) => {
|
|
15
|
-
return string === '' ? '' : (0, exports.stringToRed)(string);
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
exports.arrayToRed = arrayToRed;
|
|
19
|
-
const expectTable = (result, expectedResult) => {
|
|
20
|
-
(0, chai_1.expect)(result).to.equal(expectedResult.trim() + '\n');
|
|
21
|
-
};
|
|
22
|
-
exports.expectTable = expectTable;
|
|
23
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable max-nested-callbacks */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const chai_1 = require("chai");
|
|
5
|
-
const validateConfig_1 = require("../src/validateConfig");
|
|
6
|
-
describe('validateConfig', () => {
|
|
7
|
-
context('given invalid config', () => {
|
|
8
|
-
it('throws an error', () => {
|
|
9
|
-
(0, chai_1.expect)(() => {
|
|
10
|
-
(0, validateConfig_1.validateConfig)('config.json', { x: 1 });
|
|
11
|
-
}).to.be.throw(Error, 'Invalid config.');
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
context('given valid config', () => {
|
|
15
|
-
it('does not throw an error', () => {
|
|
16
|
-
(0, chai_1.expect)(() => {
|
|
17
|
-
(0, validateConfig_1.validateConfig)('config.json', {
|
|
18
|
-
columnDefault: {
|
|
19
|
-
width: 50,
|
|
20
|
-
},
|
|
21
|
-
columns: {
|
|
22
|
-
0: {
|
|
23
|
-
alignment: 'left',
|
|
24
|
-
width: 10,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
drawHorizontalLine: () => {
|
|
28
|
-
return false;
|
|
29
|
-
},
|
|
30
|
-
singleLine: true,
|
|
31
|
-
});
|
|
32
|
-
}).to.be.not.throw();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=validateConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ajv_1 = __importDefault(require("ajv"));
|
|
7
|
-
const ajv_keywords_1 = __importDefault(require("ajv-keywords"));
|
|
8
|
-
const json_schema_draft_06_json_1 = __importDefault(require("ajv/lib/refs/json-schema-draft-06.json"));
|
|
9
|
-
const chai_1 = require("chai");
|
|
10
|
-
const validators_1 = __importDefault(require("../src/generated/validators"));
|
|
11
|
-
const shared_json_1 = __importDefault(require("../src/schemas/shared.json"));
|
|
12
|
-
const streamConfig_json_1 = __importDefault(require("../src/schemas/streamConfig.json"));
|
|
13
|
-
const streamConfigSamples_1 = __importDefault(require("./streamConfigSamples"));
|
|
14
|
-
const validateConfig = validators_1.default['streamConfig.json'];
|
|
15
|
-
describe('streamConfig.json schema', () => {
|
|
16
|
-
let validate;
|
|
17
|
-
before(() => {
|
|
18
|
-
const ajv = new ajv_1.default({
|
|
19
|
-
allErrors: true,
|
|
20
|
-
});
|
|
21
|
-
ajv.addMetaSchema(json_schema_draft_06_json_1.default);
|
|
22
|
-
(0, ajv_keywords_1.default)(ajv, 'typeof');
|
|
23
|
-
ajv.addSchema(shared_json_1.default);
|
|
24
|
-
validate = ajv.compile(streamConfig_json_1.default);
|
|
25
|
-
});
|
|
26
|
-
it('passes validation of valid streamConfig samples', () => {
|
|
27
|
-
for (const sample of streamConfigSamples_1.default.valid) {
|
|
28
|
-
(0, chai_1.expect)(validate(sample)).to.equal(true);
|
|
29
|
-
(0, chai_1.expect)(validateConfig(sample)).to.equal(true);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
it('fails validation of invalid streamConfig samples', () => {
|
|
33
|
-
for (const sample of streamConfigSamples_1.default.invalid) {
|
|
34
|
-
(0, chai_1.expect)(validate(sample)).to.equal(false);
|
|
35
|
-
(0, chai_1.expect)(validateConfig(sample)).to.equal(false);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=validateStreamConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ajv_1 = __importDefault(require("ajv"));
|
|
7
|
-
const ajv_keywords_1 = __importDefault(require("ajv-keywords"));
|
|
8
|
-
const chai_1 = require("chai");
|
|
9
|
-
const validators_1 = __importDefault(require("../src/generated/validators"));
|
|
10
|
-
const config_json_1 = __importDefault(require("../src/schemas/config.json"));
|
|
11
|
-
const shared_json_1 = __importDefault(require("../src/schemas/shared.json"));
|
|
12
|
-
const tableConfigSamples_1 = require("./tableConfigSamples");
|
|
13
|
-
const validateConfig = validators_1.default['config.json'];
|
|
14
|
-
describe('config.json schema', () => {
|
|
15
|
-
let validate;
|
|
16
|
-
before(() => {
|
|
17
|
-
const ajv = new ajv_1.default({ allErrors: true });
|
|
18
|
-
(0, ajv_keywords_1.default)(ajv, 'typeof');
|
|
19
|
-
ajv.addSchema(shared_json_1.default);
|
|
20
|
-
validate = ajv.compile(config_json_1.default);
|
|
21
|
-
});
|
|
22
|
-
it('passes validation of valid config samples', () => {
|
|
23
|
-
for (const sample of tableConfigSamples_1.tableConfigSamples.valid) {
|
|
24
|
-
(0, chai_1.expect)(validate(sample)).to.equal(true);
|
|
25
|
-
(0, chai_1.expect)(validateConfig(sample)).to.equal(true);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
it('fails validation of invalid config samples', () => {
|
|
29
|
-
for (const sample of tableConfigSamples_1.tableConfigSamples.invalid) {
|
|
30
|
-
(0, chai_1.expect)(validate(sample)).to.equal(false);
|
|
31
|
-
(0, chai_1.expect)(validateConfig(sample)).to.equal(false);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=validateTableConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|