predefined_border_templates.js
2.1 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import _ from 'lodash';
import table, {
getBorderCharacters
} from './../../../src';
import expectTable from './expectTable';
describe('README.md usage/predefined_border_templates', () => {
let data;
before(() => {
data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C']
];
});
it('honeywell', () => {
const output = table(data, {
border: getBorderCharacters('honeywell')
});
// eslint-disable-next-line no-restricted-syntax
expectTable(output, `
╔════╤════╤════╗
║ 0A │ 0B │ 0C ║
╟────┼────┼────╢
║ 1A │ 1B │ 1C ║
╟────┼────┼────╢
║ 2A │ 2B │ 2C ║
╚════╧════╧════╝
`);
});
it('norc', () => {
const output = table(data, {
border: getBorderCharacters('norc')
});
// eslint-disable-next-line no-restricted-syntax
expectTable(output, `
┌────┬────┬────┐
│ 0A │ 0B │ 0C │
├────┼────┼────┤
│ 1A │ 1B │ 1C │
├────┼────┼────┤
│ 2A │ 2B │ 2C │
└────┴────┴────┘
`);
});
it('ramac', () => {
const output = table(data, {
border: getBorderCharacters('ramac')
});
// eslint-disable-next-line no-restricted-syntax
expectTable(output, `
+----+----+----+
| 0A | 0B | 0C |
|----|----|----|
| 1A | 1B | 1C |
|----|----|----|
| 2A | 2B | 2C |
+----+----+----+
`);
});
it('void', () => {
const output = table(data, {
border: getBorderCharacters('void')
});
expectTable(_.trim(output) + '\n', '0A 0B 0C \n\n 1A 1B 1C \n\n 2A 2B 2C');
});
it('borderless', () => {
const output = table(data, {
border: getBorderCharacters('void'),
columnDefault: {
paddingLeft: 0,
paddingRight: 1
},
drawHorizontalLine: () => {
return false;
}
});
expectTable(_.trim(output) + '\n', '0A 0B 0C \n1A 1B 1C \n2A 2B 2C');
});
});