1
0
mirror of https://github.com/thangisme/notes.git synced 2024-07-01 04:05:26 +00:00
notes/node_modules/table/test/README/usage/predefined_border_templates.js

93 lines
2.1 KiB
JavaScript
Raw Normal View History

2017-03-09 18:16:08 +00:00
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');
});
});