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.
Files changed (87) hide show
  1. package/package.json +4 -4
  2. package/dist/test/README/api/getBorderCharacters.d.ts +0 -1
  3. package/dist/test/README/api/getBorderCharacters.js +0 -76
  4. package/dist/test/README/api/stream/streaming.d.ts +0 -1
  5. package/dist/test/README/api/stream/streaming.js +0 -41
  6. package/dist/test/README/api/table/border.d.ts +0 -1
  7. package/dist/test/README/api/table/border.js +0 -45
  8. package/dist/test/README/api/table/column/alignment.d.ts +0 -1
  9. package/dist/test/README/api/table/column/alignment.js +0 -34
  10. package/dist/test/README/api/table/column/padding.d.ts +0 -1
  11. package/dist/test/README/api/table/column/padding.js +0 -36
  12. package/dist/test/README/api/table/column/truncate.d.ts +0 -1
  13. package/dist/test/README/api/table/column/truncate.js +0 -29
  14. package/dist/test/README/api/table/column/verticalAlignment.d.ts +0 -1
  15. package/dist/test/README/api/table/column/verticalAlignment.js +0 -28
  16. package/dist/test/README/api/table/column/width.d.ts +0 -1
  17. package/dist/test/README/api/table/column/width.js +0 -30
  18. package/dist/test/README/api/table/column/wrapWord.d.ts +0 -1
  19. package/dist/test/README/api/table/column/wrapWord.js +0 -51
  20. package/dist/test/README/api/table/drawHorizontalLine.d.ts +0 -1
  21. package/dist/test/README/api/table/drawHorizontalLine.js +0 -33
  22. package/dist/test/README/api/table/drawVerticalLine.d.ts +0 -1
  23. package/dist/test/README/api/table/drawVerticalLine.js +0 -35
  24. package/dist/test/README/api/table/header.d.ts +0 -1
  25. package/dist/test/README/api/table/header.js +0 -35
  26. package/dist/test/README/api/table/singleLine.d.ts +0 -1
  27. package/dist/test/README/api/table/singleLine.js +0 -35
  28. package/dist/test/README/demo.d.ts +0 -1
  29. package/dist/test/README/demo.js +0 -71
  30. package/dist/test/README/usage.d.ts +0 -1
  31. package/dist/test/README/usage.js +0 -24
  32. package/dist/test/alignString.d.ts +0 -1
  33. package/dist/test/alignString.js +0 -124
  34. package/dist/test/alignTableData.d.ts +0 -1
  35. package/dist/test/alignTableData.js +0 -63
  36. package/dist/test/calculateCellHeight.d.ts +0 -1
  37. package/dist/test/calculateCellHeight.js +0 -28
  38. package/dist/test/calculateCellWidths.d.ts +0 -1
  39. package/dist/test/calculateCellWidths.js +0 -27
  40. package/dist/test/calculateColumnWidths.d.ts +0 -1
  41. package/dist/test/calculateColumnWidths.js +0 -54
  42. package/dist/test/calculateRowHeights.d.ts +0 -1
  43. package/dist/test/calculateRowHeights.js +0 -61
  44. package/dist/test/createStream.d.ts +0 -1
  45. package/dist/test/createStream.js +0 -122
  46. package/dist/test/drawBorder.d.ts +0 -1
  47. package/dist/test/drawBorder.js +0 -139
  48. package/dist/test/drawHeader.d.ts +0 -1
  49. package/dist/test/drawHeader.js +0 -172
  50. package/dist/test/drawRow.d.ts +0 -1
  51. package/dist/test/drawRow.js +0 -54
  52. package/dist/test/getBorderCharacters.d.ts +0 -1
  53. package/dist/test/getBorderCharacters.js +0 -104
  54. package/dist/test/makeConfig.d.ts +0 -1
  55. package/dist/test/makeConfig.js +0 -152
  56. package/dist/test/makeStreamConfig.d.ts +0 -1
  57. package/dist/test/makeStreamConfig.js +0 -106
  58. package/dist/test/mapDataUsingRowHeights.d.ts +0 -1
  59. package/dist/test/mapDataUsingRowHeights.js +0 -150
  60. package/dist/test/padTableData.d.ts +0 -1
  61. package/dist/test/padTableData.js +0 -62
  62. package/dist/test/streamConfigSamples.d.ts +0 -6
  63. package/dist/test/streamConfigSamples.js +0 -287
  64. package/dist/test/stringifyTableData.d.ts +0 -1
  65. package/dist/test/stringifyTableData.js +0 -17
  66. package/dist/test/table.d.ts +0 -1
  67. package/dist/test/table.js +0 -171
  68. package/dist/test/tableConfigSamples.d.ts +0 -5
  69. package/dist/test/tableConfigSamples.js +0 -202
  70. package/dist/test/truncateTableData.d.ts +0 -1
  71. package/dist/test/truncateTableData.js +0 -92
  72. package/dist/test/utils.d.ts +0 -7
  73. package/dist/test/utils.js +0 -23
  74. package/dist/test/validateConfig.d.ts +0 -1
  75. package/dist/test/validateConfig.js +0 -36
  76. package/dist/test/validateStreamConfig.d.ts +0 -1
  77. package/dist/test/validateStreamConfig.js +0 -39
  78. package/dist/test/validateTableConfig.d.ts +0 -1
  79. package/dist/test/validateTableConfig.js +0 -35
  80. package/dist/test/validateTableData.d.ts +0 -1
  81. package/dist/test/validateTableData.js +0 -106
  82. package/dist/test/wrapCell.d.ts +0 -1
  83. package/dist/test/wrapCell.js +0 -114
  84. package/dist/test/wrapString.d.ts +0 -1
  85. package/dist/test/wrapString.js +0 -45
  86. package/dist/test/wrapWord.d.ts +0 -1
  87. package/dist/test/wrapWord.js +0 -94
@@ -1,139 +0,0 @@
1
- "use strict";
2
- /* eslint-disable sort-keys-fix/sort-keys-fix */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const chai_1 = require("chai");
5
- const drawBorder_1 = require("../src/drawBorder");
6
- const makeTableConfig_1 = require("../src/makeTableConfig");
7
- const defaultDrawVerticalLine = () => {
8
- return true;
9
- };
10
- const customDrawVerticalLine = (index, size) => {
11
- return index === size - 1;
12
- };
13
- context('drawBorder', () => {
14
- it('draws a border using parts', () => {
15
- const config = {
16
- drawVerticalLine: defaultDrawVerticalLine,
17
- separator: {
18
- left: '╔',
19
- right: '╗',
20
- body: '═',
21
- join: '╤',
22
- },
23
- };
24
- (0, chai_1.expect)((0, drawBorder_1.drawBorder)([1], config)).to.equal('╔═╗\n');
25
- (0, chai_1.expect)((0, drawBorder_1.drawBorder)([1, 1], config)).to.equal('╔═╤═╗\n');
26
- (0, chai_1.expect)((0, drawBorder_1.drawBorder)([5, 10], config)).to.equal('╔═════╤══════════╗\n');
27
- (0, chai_1.expect)((0, drawBorder_1.drawBorder)([5, 10], {
28
- ...config,
29
- drawVerticalLine: customDrawVerticalLine,
30
- })).to.equal('═════╤══════════\n');
31
- });
32
- });
33
- context('drawBorderTop', () => {
34
- it('draws a border using parts', () => {
35
- const config = {
36
- border: {
37
- topLeft: '╔',
38
- topRight: '╗',
39
- topBody: '═',
40
- topJoin: '╤',
41
- },
42
- drawVerticalLine: defaultDrawVerticalLine,
43
- };
44
- (0, chai_1.expect)((0, drawBorder_1.drawBorderTop)([1], config)).to.equal('╔═╗\n');
45
- (0, chai_1.expect)((0, drawBorder_1.drawBorderTop)([1, 1], config)).to.equal('╔═╤═╗\n');
46
- (0, chai_1.expect)((0, drawBorder_1.drawBorderTop)([5, 10], config)).to.equal('╔═════╤══════════╗\n');
47
- (0, chai_1.expect)((0, drawBorder_1.drawBorderTop)([5, 10], {
48
- ...config,
49
- drawVerticalLine: customDrawVerticalLine,
50
- })).to.equal('═════╤══════════\n');
51
- });
52
- it('no leading new line if borderless', () => {
53
- const config = {
54
- border: {
55
- topLeft: '',
56
- topRight: '',
57
- topBody: '',
58
- topJoin: '',
59
- },
60
- drawVerticalLine: defaultDrawVerticalLine,
61
- };
62
- (0, chai_1.expect)((0, drawBorder_1.drawBorderTop)([1], config)).to.equal('');
63
- (0, chai_1.expect)((0, drawBorder_1.drawBorderTop)([1, 1], config)).to.equal('');
64
- (0, chai_1.expect)((0, drawBorder_1.drawBorderTop)([5, 10], config)).to.equal('');
65
- (0, chai_1.expect)((0, drawBorder_1.drawBorderTop)([5, 10], {
66
- ...config,
67
- drawVerticalLine: customDrawVerticalLine,
68
- })).to.equal('');
69
- });
70
- });
71
- context('drawBorderJoin', () => {
72
- it('draws a border using parts', () => {
73
- const config = {
74
- border: {
75
- joinBody: '─',
76
- joinLeft: '╟',
77
- joinRight: '╢',
78
- joinJoin: '┼',
79
- },
80
- drawVerticalLine: defaultDrawVerticalLine,
81
- };
82
- (0, chai_1.expect)((0, drawBorder_1.drawBorderJoin)([1], config)).to.equal('╟─╢\n');
83
- (0, chai_1.expect)((0, drawBorder_1.drawBorderJoin)([1, 1], config)).to.equal('╟─┼─╢\n');
84
- (0, chai_1.expect)((0, drawBorder_1.drawBorderJoin)([5, 10], config)).to.equal('╟─────┼──────────╢\n');
85
- (0, chai_1.expect)((0, drawBorder_1.drawBorderJoin)([5, 10], {
86
- ...config,
87
- drawVerticalLine: customDrawVerticalLine,
88
- })).to.equal('─────┼──────────\n');
89
- });
90
- });
91
- context('drawBorderBottom', () => {
92
- it('draws a border using parts', () => {
93
- const config = {
94
- border: {
95
- bottomBody: '═',
96
- bottomJoin: '╧',
97
- bottomLeft: '╚',
98
- bottomRight: '╝',
99
- },
100
- drawVerticalLine: defaultDrawVerticalLine,
101
- };
102
- (0, chai_1.expect)((0, drawBorder_1.drawBorderBottom)([1], config)).to.equal('╚═╝\n');
103
- (0, chai_1.expect)((0, drawBorder_1.drawBorderBottom)([1, 1], config)).to.equal('╚═╧═╝\n');
104
- (0, chai_1.expect)((0, drawBorder_1.drawBorderBottom)([5, 10], config)).to.equal('╚═════╧══════════╝\n');
105
- (0, chai_1.expect)((0, drawBorder_1.drawBorderBottom)([5, 10], {
106
- ...config,
107
- drawVerticalLine: customDrawVerticalLine,
108
- })).to.equal('═════╧══════════\n');
109
- });
110
- });
111
- context('tableBorderGetter', () => {
112
- context('when config.header is undefined', () => {
113
- it('draw the table border normally', () => {
114
- const config = (0, makeTableConfig_1.makeTableConfig)([['a', 'b', 'c']], {
115
- header: undefined,
116
- });
117
- const getter = (0, drawBorder_1.createTableBorderGetter)([2, 1, 3], config);
118
- (0, chai_1.expect)(getter(0, 3)).to.equal('╔══╤═╤═══╗\n');
119
- (0, chai_1.expect)(getter(1, 3)).to.equal('╟──┼─┼───╢\n');
120
- (0, chai_1.expect)(getter(2, 3)).to.equal('╟──┼─┼───╢\n');
121
- (0, chai_1.expect)(getter(3, 3)).to.equal('╚══╧═╧═══╝\n');
122
- });
123
- });
124
- context('when config.header is defined', () => {
125
- it('draws the borders that modify for header', () => {
126
- const config = (0, makeTableConfig_1.makeTableConfig)([['a', 'b', 'c']], {
127
- header: {
128
- content: 'ddd',
129
- },
130
- });
131
- const getter = (0, drawBorder_1.createTableBorderGetter)([2, 1, 3], config);
132
- (0, chai_1.expect)(getter(0, 3)).to.equal('╔════════╗\n');
133
- (0, chai_1.expect)(getter(1, 3)).to.equal('╟──┬─┬───╢\n');
134
- (0, chai_1.expect)(getter(2, 3)).to.equal('╟──┼─┼───╢\n');
135
- (0, chai_1.expect)(getter(3, 3)).to.equal('╚══╧═╧═══╝\n');
136
- });
137
- });
138
- });
139
- //# sourceMappingURL=drawBorder.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,172 +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 drawHeader_1 = require("../src/drawHeader");
6
- const makeTableConfig_1 = require("../src/makeTableConfig");
7
- const utils_1 = require("./utils");
8
- const basicContent = 'Lorem ipsum dolor sit amet';
9
- const basicRows = [['aaa', 'bb', 'c']];
10
- const createHeader = (headerWidth = 7, headerConfig) => {
11
- const config = (0, makeTableConfig_1.makeTableConfig)(basicRows, {
12
- header: headerConfig,
13
- });
14
- return (0, drawHeader_1.drawHeader)(headerWidth, config);
15
- };
16
- context('drawHeader', () => {
17
- context('when no given header', () => {
18
- it('throws an error', () => {
19
- const config = (0, makeTableConfig_1.makeTableConfig)(basicRows, {
20
- header: undefined,
21
- });
22
- (0, chai_1.expect)(() => {
23
- return (0, drawHeader_1.drawHeader)(7, config);
24
- }).to.throw('Can not draw header without header configuration');
25
- });
26
- });
27
- context('width', () => {
28
- it('forces to the given width', () => {
29
- const header = createHeader(7, {
30
- content: basicContent,
31
- });
32
- (0, chai_1.expect)(header).to.equal(`
33
- ║ Lorem i ║
34
- ║ psum do ║
35
- ║ lor sit ║
36
- ║ amet ║
37
- `.trimLeft());
38
- });
39
- });
40
- context('truncate', () => {
41
- it('truncates to the truncation value', () => {
42
- const header = createHeader(7, {
43
- content: basicContent,
44
- truncate: 7,
45
- });
46
- (0, chai_1.expect)(header).to.equal('║ Lorem … ║\n');
47
- });
48
- });
49
- context('wrapWord', () => {
50
- context('wrapWord = false', () => {
51
- it('slices to the given width', () => {
52
- const header = createHeader(7, {
53
- content: basicContent,
54
- wrapWord: false,
55
- });
56
- (0, chai_1.expect)(header).to.equal(`
57
- ║ Lorem i ║
58
- ║ psum do ║
59
- ║ lor sit ║
60
- ║ amet ║
61
- `.trimLeft());
62
- });
63
- });
64
- context('wrapWord = true', () => {
65
- it('wraps word properly', () => {
66
- const header = createHeader(7, {
67
- content: basicContent,
68
- wrapWord: true,
69
- });
70
- (0, chai_1.expect)(header).to.equal(`
71
- ║ Lorem ║
72
- ║ ipsum ║
73
- ║ dolor ║
74
- ║ sit ║
75
- ║ amet ║
76
- `.trimLeft());
77
- });
78
- });
79
- });
80
- context('alignment', () => {
81
- context('left', () => {
82
- it('aligns left', () => {
83
- const header = createHeader(7, {
84
- alignment: 'left',
85
- content: basicContent,
86
- wrapWord: true,
87
- });
88
- (0, chai_1.expect)(header).to.equal(`
89
- ║ Lorem ║
90
- ║ ipsum ║
91
- ║ dolor ║
92
- ║ sit ║
93
- ║ amet ║
94
- `.trimLeft());
95
- });
96
- });
97
- context('center', () => {
98
- it('aligns center', () => {
99
- const header = createHeader(7, {
100
- alignment: 'center',
101
- content: basicContent,
102
- wrapWord: true,
103
- });
104
- (0, chai_1.expect)(header).to.equal(`
105
- ║ Lorem ║
106
- ║ ipsum ║
107
- ║ dolor ║
108
- ║ sit ║
109
- ║ amet ║
110
- `.trimLeft());
111
- });
112
- });
113
- context('right', () => {
114
- it('aligns right', () => {
115
- const header = createHeader(7, {
116
- alignment: 'right',
117
- content: basicContent,
118
- wrapWord: true,
119
- });
120
- (0, chai_1.expect)(header).to.equal(`
121
- ║ Lorem ║
122
- ║ ipsum ║
123
- ║ dolor ║
124
- ║ sit ║
125
- ║ amet ║
126
- `.trimLeft());
127
- });
128
- });
129
- context('justify', () => {
130
- it('aligns justify', () => {
131
- const header = createHeader(12, {
132
- alignment: 'justify',
133
- content: basicContent,
134
- wrapWord: true,
135
- });
136
- (0, chai_1.expect)(header).to.equal(`
137
- ║ Lorem ipsum ║
138
- ║ dolor sit ║
139
- ║ amet ║
140
- `.trimLeft());
141
- });
142
- });
143
- });
144
- context('padding', () => {
145
- it('pads properly', () => {
146
- const header = createHeader(12, {
147
- content: basicContent,
148
- paddingLeft: 2,
149
- paddingRight: 3,
150
- });
151
- (0, chai_1.expect)(header).to.equal(`
152
- ║ Lorem ipsum ║
153
- ║ dolor sit am ║
154
- ║ et ║
155
- `.trimLeft());
156
- });
157
- });
158
- context('mixed with ansi word', () => {
159
- it('works properly', () => {
160
- const header = createHeader(16, {
161
- content: `${utils_1.openBold}This is the header with ${utils_1.openRed}ansi words${utils_1.closeRed}${utils_1.closeBold}`,
162
- wrapWord: true,
163
- });
164
- (0, chai_1.expect)(header).to.equal(`
165
- ║ ${utils_1.openBold}This is the${utils_1.closeBold} ║
166
- ║ ${utils_1.openBold}header with ${utils_1.openRed}ansi${utils_1.closeRed}${utils_1.closeBold} ║
167
- ║ ${utils_1.openBold}${utils_1.openRed}words${utils_1.closeBold}${utils_1.closeRed} ║
168
- `.trimLeft());
169
- });
170
- });
171
- });
172
- //# sourceMappingURL=drawHeader.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- const drawRow_1 = require("../src/drawRow");
5
- const drawVerticalLine = () => {
6
- return true;
7
- };
8
- describe('drawRow', () => {
9
- context('default drawVerticalLine', () => {
10
- it('draws a row using all parts', () => {
11
- const border = {
12
- bodyJoin: '│',
13
- bodyLeft: '║',
14
- bodyRight: '║',
15
- };
16
- const config = {
17
- border,
18
- drawVerticalLine,
19
- };
20
- (0, chai_1.expect)((0, drawRow_1.drawRow)([], config)).to.equal('║║\n');
21
- (0, chai_1.expect)((0, drawRow_1.drawRow)(['a'], config)).to.equal('║a║\n');
22
- (0, chai_1.expect)((0, drawRow_1.drawRow)(['a', ' b '], config)).to.equal('║a│ b ║\n');
23
- });
24
- });
25
- context('custom drawVerticalLine', () => {
26
- it('draws the vertical line when the drawVerticalLine returns true', () => {
27
- const rows = [' a ', ' b ', ' c '];
28
- const border = {
29
- bodyJoin: '│',
30
- bodyLeft: '║',
31
- bodyRight: '║',
32
- };
33
- (0, chai_1.expect)((0, drawRow_1.drawRow)(rows, {
34
- border,
35
- drawVerticalLine: (index) => {
36
- return index === 0;
37
- },
38
- })).to.equal('║ a b c \n');
39
- (0, chai_1.expect)((0, drawRow_1.drawRow)(rows, {
40
- border,
41
- drawVerticalLine: (index) => {
42
- return index % 2 === 0;
43
- },
44
- })).to.equal('║ a b │ c \n');
45
- (0, chai_1.expect)((0, drawRow_1.drawRow)(rows, {
46
- border,
47
- drawVerticalLine: (index, size) => {
48
- return index > 0 && index <= size;
49
- },
50
- })).to.equal(' a │ b │ c ║\n');
51
- });
52
- });
53
- });
54
- //# sourceMappingURL=drawRow.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,104 +0,0 @@
1
- "use strict";
2
- /* eslint-disable max-nested-callbacks */
3
- /* eslint-disable sort-keys-fix/sort-keys-fix */
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- const chai_1 = require("chai");
6
- const src_1 = require("../src");
7
- describe('getBorderCharacters', () => {
8
- context('given name \'honeywell\'', () => {
9
- it('returns the \'honeywell\' template', () => {
10
- (0, chai_1.expect)((0, src_1.getBorderCharacters)('honeywell')).to.be.deep.equal({
11
- headerJoin: '┬',
12
- bodyJoin: '│',
13
- bodyLeft: '║',
14
- bodyRight: '║',
15
- bottomJoin: '╧',
16
- bottomLeft: '╚',
17
- bottomRight: '╝',
18
- bottomBody: '═',
19
- joinBody: '─',
20
- joinJoin: '┼',
21
- joinLeft: '╟',
22
- joinRight: '╢',
23
- topBody: '═',
24
- topJoin: '╤',
25
- topLeft: '╔',
26
- topRight: '╗',
27
- });
28
- });
29
- });
30
- context('given name \'norc\'', () => {
31
- it('returns the \'norc\' template', () => {
32
- (0, chai_1.expect)((0, src_1.getBorderCharacters)('norc')).to.be.deep.equal({
33
- headerJoin: '┬',
34
- bodyJoin: '│',
35
- bodyLeft: '│',
36
- bodyRight: '│',
37
- bottomJoin: '┴',
38
- bottomLeft: '└',
39
- bottomRight: '┘',
40
- bottomBody: '─',
41
- joinJoin: '┼',
42
- joinLeft: '├',
43
- joinRight: '┤',
44
- joinBody: '─',
45
- topBody: '─',
46
- topJoin: '┬',
47
- topLeft: '┌',
48
- topRight: '┐',
49
- });
50
- });
51
- });
52
- context('given name \'ramac\'', () => {
53
- it('returns the \'ramac\' template', () => {
54
- (0, chai_1.expect)((0, src_1.getBorderCharacters)('ramac')).to.be.deep.equal({
55
- headerJoin: '+',
56
- bodyJoin: '|',
57
- bodyLeft: '|',
58
- bodyRight: '|',
59
- bottomJoin: '+',
60
- bottomLeft: '+',
61
- bottomRight: '+',
62
- bottomBody: '-',
63
- joinJoin: '|',
64
- joinLeft: '|',
65
- joinRight: '|',
66
- joinBody: '-',
67
- topBody: '-',
68
- topJoin: '+',
69
- topLeft: '+',
70
- topRight: '+',
71
- });
72
- });
73
- });
74
- context('given name \'void\'', () => {
75
- it('returns the \'void\' template', () => {
76
- (0, chai_1.expect)((0, src_1.getBorderCharacters)('void')).to.be.deep.equal({
77
- headerJoin: '',
78
- bodyJoin: '',
79
- bodyLeft: '',
80
- bodyRight: '',
81
- bottomJoin: '',
82
- bottomLeft: '',
83
- bottomRight: '',
84
- bottomBody: '',
85
- joinJoin: '',
86
- joinLeft: '',
87
- joinRight: '',
88
- joinBody: '',
89
- topBody: '',
90
- topJoin: '',
91
- topLeft: '',
92
- topRight: '',
93
- });
94
- });
95
- });
96
- context('given another name', () => {
97
- it('throws an error', () => {
98
- (0, chai_1.expect)(() => {
99
- return (0, src_1.getBorderCharacters)('bold');
100
- }).to.throw(Error, 'Unknown border template "bold".');
101
- });
102
- });
103
- });
104
- //# sourceMappingURL=getBorderCharacters.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,152 +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
- describe('makeConfig', () => {
7
- const rows = [['aaaaa']];
8
- it('does not affect the parameter configuration object', () => {
9
- const config = {};
10
- (0, makeTableConfig_1.makeTableConfig)(rows, config);
11
- (0, chai_1.expect)(config).to.deep.equal({});
12
- });
13
- context('column', () => {
14
- context('"alignment"', () => {
15
- context('is not provided', () => {
16
- it('defaults to "left"', () => {
17
- const config = (0, makeTableConfig_1.makeTableConfig)(rows);
18
- (0, chai_1.expect)(config.columns[0].alignment).to.equal('left');
19
- });
20
- });
21
- context('is provided', () => {
22
- it('uses the custom value', () => {
23
- const config = (0, makeTableConfig_1.makeTableConfig)(rows, { columns: {
24
- 0: { alignment: 'center' },
25
- } });
26
- (0, chai_1.expect)(config.columns[0].alignment).to.equal('center');
27
- });
28
- });
29
- });
30
- context('"width"', () => {
31
- context('is not provided', () => {
32
- it('defaults to the maximum column width', () => {
33
- const config = (0, makeTableConfig_1.makeTableConfig)(rows);
34
- (0, chai_1.expect)(config.columns[0].width).to.equal(5);
35
- });
36
- });
37
- context('is provided', () => {
38
- it('uses the custom value', () => {
39
- const config = (0, makeTableConfig_1.makeTableConfig)(rows, { columns: { 0: { width: 7 } } });
40
- (0, chai_1.expect)(config.columns[0].width).to.equal(7);
41
- });
42
- });
43
- });
44
- context('"padding"', () => {
45
- context('is not provided', () => {
46
- it('defaults to 1', () => {
47
- const config = (0, makeTableConfig_1.makeTableConfig)(rows);
48
- (0, chai_1.expect)(config.columns[0].paddingLeft).to.equal(1);
49
- (0, chai_1.expect)(config.columns[0].paddingRight).to.equal(1);
50
- });
51
- });
52
- context('is provided', () => {
53
- it('uses the custom value', () => {
54
- const config = (0, makeTableConfig_1.makeTableConfig)(rows, { columns: { 0: { paddingLeft: 3,
55
- paddingRight: 2 } } });
56
- (0, chai_1.expect)(config.columns[0].paddingLeft).to.equal(3);
57
- (0, chai_1.expect)(config.columns[0].paddingRight).to.equal(2);
58
- });
59
- });
60
- });
61
- });
62
- context('"drawVerticalLine', () => {
63
- context('is not provided', () => {
64
- it('defaults to retuning true', () => {
65
- const config = (0, makeTableConfig_1.makeTableConfig)(rows);
66
- (0, chai_1.expect)(config.drawVerticalLine(-1, -1)).to.equal(true);
67
- });
68
- });
69
- context('is provided', () => {
70
- it('uses the custom function', () => {
71
- const config = (0, makeTableConfig_1.makeTableConfig)(rows, { drawVerticalLine: () => {
72
- return false;
73
- } });
74
- (0, chai_1.expect)(config.drawVerticalLine(-1, -1)).to.equal(false);
75
- });
76
- });
77
- });
78
- context('"drawHorizontalLine', () => {
79
- context('is not provided', () => {
80
- it('defaults to retuning true', () => {
81
- const config = (0, makeTableConfig_1.makeTableConfig)([['aaaaa']]);
82
- (0, chai_1.expect)(config.drawHorizontalLine(-1, -1)).to.equal(true);
83
- });
84
- });
85
- context('is provided', () => {
86
- it('uses the custom function', () => {
87
- const config = (0, makeTableConfig_1.makeTableConfig)(rows, { drawHorizontalLine: () => {
88
- return false;
89
- } });
90
- (0, chai_1.expect)(config.drawHorizontalLine(-1, -1)).to.be.equal(false);
91
- });
92
- });
93
- });
94
- context('"singleLine', () => {
95
- context('is not provided', () => {
96
- it('defaults to retuning false', () => {
97
- const config = (0, makeTableConfig_1.makeTableConfig)(rows);
98
- (0, chai_1.expect)(config.singleLine).to.equal(false);
99
- });
100
- });
101
- context('is provided', () => {
102
- it('uses the custom value', () => {
103
- const config = (0, makeTableConfig_1.makeTableConfig)(rows, { singleLine: true });
104
- (0, chai_1.expect)(config.singleLine).to.equal(true);
105
- });
106
- });
107
- });
108
- context('header', () => {
109
- context('when no given', () => {
110
- it('returns undefined', () => {
111
- const config = (0, makeTableConfig_1.makeTableConfig)(rows, { header: undefined });
112
- (0, chai_1.expect)(config.header).to.equal(undefined);
113
- });
114
- });
115
- context('when given content only', () => {
116
- it('returns the default config', () => {
117
- const config = (0, makeTableConfig_1.makeTableConfig)(rows, { header: {
118
- content: 'bb',
119
- } });
120
- (0, chai_1.expect)(config.header).to.deep.equal({
121
- alignment: 'center',
122
- content: 'bb',
123
- paddingLeft: 1,
124
- paddingRight: 1,
125
- truncate: Number.POSITIVE_INFINITY,
126
- wrapWord: false,
127
- });
128
- });
129
- });
130
- context('when given extra configs', () => {
131
- it('overrides the default', () => {
132
- const config = (0, makeTableConfig_1.makeTableConfig)(rows, { header: {
133
- alignment: 'center',
134
- content: 'bb',
135
- paddingLeft: 2,
136
- paddingRight: 3,
137
- truncate: 5,
138
- wrapWord: true,
139
- } });
140
- (0, chai_1.expect)(config.header).to.deep.equal({
141
- alignment: 'center',
142
- content: 'bb',
143
- paddingLeft: 2,
144
- paddingRight: 3,
145
- truncate: 5,
146
- wrapWord: true,
147
- });
148
- });
149
- });
150
- });
151
- });
152
- //# sourceMappingURL=makeConfig.js.map
@@ -1 +0,0 @@
1
- export {};