1
0
mirror of https://github.com/thangisme/notes.git synced 2024-06-29 00:45:32 +00:00
notes/node_modules/table/test/README/usage/predefined_border_templates.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

93 lines
2.1 KiB
JavaScript

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');
});
});