mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 13:23:32 -06:00
Initial commit
This commit is contained in:
27
node_modules/table/test/README/usage/basic.js
generated
vendored
Normal file
27
node_modules/table/test/README/usage/basic.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('basic', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
const output = table(data);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔════╤════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────┼────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════╧════╧════╝
|
||||
`);
|
||||
});
|
||||
});
|
47
node_modules/table/test/README/usage/cell_content_alignment.js
generated
vendored
Normal file
47
node_modules/table/test/README/usage/cell_content_alignment.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('cell_content_alignment', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
alignment: 'left',
|
||||
width: 10
|
||||
},
|
||||
1: {
|
||||
alignment: 'center',
|
||||
width: 10
|
||||
},
|
||||
2: {
|
||||
alignment: 'right',
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// console.log(output);
|
||||
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
expectTable(output, `
|
||||
╔════════════╤════════════╤════════════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────────────┼────────────┼────────────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────────────┼────────────┼────────────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════════════╧════════════╧════════════╝
|
||||
`);
|
||||
/* eslint-enable no-restricted-syntax */
|
||||
});
|
||||
});
|
35
node_modules/table/test/README/usage/column_width.js
generated
vendored
Normal file
35
node_modules/table/test/README/usage/column_width.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('column_width', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
1: {
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔════╤════════════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────────────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────┼────────────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════╧════════════╧════╝
|
||||
`);
|
||||
});
|
||||
});
|
52
node_modules/table/test/README/usage/custom_border.js
generated
vendored
Normal file
52
node_modules/table/test/README/usage/custom_border.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('usage/custom_border', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
const config = {
|
||||
border: {
|
||||
topBody: '─',
|
||||
topJoin: '┬',
|
||||
topLeft: '┌',
|
||||
topRight: '┐',
|
||||
|
||||
bottomBody: '─',
|
||||
bottomJoin: '┴',
|
||||
bottomLeft: '└',
|
||||
bottomRight: '┘',
|
||||
|
||||
bodyLeft: '│',
|
||||
bodyRight: '│',
|
||||
bodyJoin: '│',
|
||||
|
||||
joinBody: '─',
|
||||
joinLeft: '├',
|
||||
joinRight: '┤',
|
||||
joinJoin: '┼'
|
||||
}
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
┌────┬────┬────┐
|
||||
│ 0A │ 0B │ 0C │
|
||||
├────┼────┼────┤
|
||||
│ 1A │ 1B │ 1C │
|
||||
├────┼────┼────┤
|
||||
│ 2A │ 2B │ 2C │
|
||||
└────┴────┴────┘
|
||||
`);
|
||||
});
|
||||
});
|
43
node_modules/table/test/README/usage/draw_horizontal_line.js
generated
vendored
Normal file
43
node_modules/table/test/README/usage/draw_horizontal_line.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('usage/draw_horizontal_line', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C'],
|
||||
['3A', '3B', '3C'],
|
||||
['4A', '4B', '4C']
|
||||
];
|
||||
|
||||
const options = {
|
||||
/**
|
||||
* @typedef {Function} drawJoin
|
||||
* @param {number} index
|
||||
* @param {number} size
|
||||
* @returns {boolean}
|
||||
*/
|
||||
drawHorizontalLine: (index, size) => {
|
||||
return index === 0 || index === 1 || index === size - 1 || index === size;
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, options);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔════╤════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
║ 2A │ 2B │ 2C ║
|
||||
║ 3A │ 3B │ 3C ║
|
||||
╟────┼────┼────╢
|
||||
║ 4A │ 4B │ 4C ║
|
||||
╚════╧════╧════╝
|
||||
`);
|
||||
});
|
||||
});
|
13
node_modules/table/test/README/usage/expectTable.js
generated
vendored
Normal file
13
node_modules/table/test/README/usage/expectTable.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import _ from 'lodash';
|
||||
|
||||
/**
|
||||
* @param {string} result
|
||||
* @param {string} expectedResult
|
||||
* @returns {undefined}
|
||||
*/
|
||||
export default (result, expectedResult) => {
|
||||
expect(result).to.equal(_.trim(expectedResult) + '\n');
|
||||
};
|
68
node_modules/table/test/README/usage/moon_mission.js
generated
vendored
Normal file
68
node_modules/table/test/README/usage/moon_mission.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import _ from 'lodash';
|
||||
import chalk from 'chalk';
|
||||
import {
|
||||
table,
|
||||
getBorderCharacters
|
||||
} from './../../../src';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('moon_mission', () => {
|
||||
const data = [
|
||||
[
|
||||
chalk.bold('Spacecraft'),
|
||||
chalk.bold('Launch Date'),
|
||||
chalk.bold('Operator'),
|
||||
chalk.bold('Outcome'),
|
||||
chalk.bold('Remarks')
|
||||
],
|
||||
[
|
||||
'Able I',
|
||||
'17 August 1958',
|
||||
'USAF',
|
||||
chalk.white.bold.bgRed('Launch failure'),
|
||||
'First attempted launch beyond Earth orbit; failed to orbit due to turbopump gearbox malfunction resulting in first stage explosion.[3] Reached apogee of 16 kilometres (9.9 mi)'
|
||||
],
|
||||
[
|
||||
'Luna 2',
|
||||
'12 September 1959',
|
||||
'OKB-1',
|
||||
chalk.black.bgGreen('Successful'),
|
||||
'Successful impact at 21:02 on 14 September 1959. First spacecraft to reach lunar surface'
|
||||
],
|
||||
[
|
||||
'Lunar Orbiter 1',
|
||||
'10 August 1966',
|
||||
'NASA',
|
||||
chalk.black.bgYellow('Partial failure'),
|
||||
'Orbital insertion at around 15:36 UTC on 14 August. Deorbited early due to lack of fuel and to avoid communications interference with the next mission, impacted the Moon at 13:30 UTC on 29 October 1966.'
|
||||
],
|
||||
[
|
||||
'Apollo 8',
|
||||
'21 December 1968',
|
||||
'NASA',
|
||||
chalk.black.bgGreen('Successful'),
|
||||
'First manned mission to the Moon; entered orbit around the Moon with four-minute burn beginning at 09:59:52 UTC on 24 December. Completed ten orbits of the Moon before returning to Earth with an engine burn at 06:10:16 UTC on 25 December. Landed in the Pacific Ocean at 15:51 UTC on 27 December.'
|
||||
],
|
||||
[
|
||||
'Apollo 11',
|
||||
'16 July 1969',
|
||||
'NASA',
|
||||
chalk.black.bgGreen('Successful'),
|
||||
'First manned landing on the Moon. LM landed at 20:17 UTC on 20 July 1969'
|
||||
]
|
||||
];
|
||||
|
||||
const tableBorder = _.mapValues(getBorderCharacters('honeywell'), (char) => {
|
||||
return chalk.gray(char);
|
||||
});
|
||||
|
||||
table(data, {
|
||||
border: tableBorder,
|
||||
columns: {
|
||||
4: {
|
||||
width: 50
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
41
node_modules/table/test/README/usage/padding_cell_content.js
generated
vendored
Normal file
41
node_modules/table/test/README/usage/padding_cell_content.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('usage/padding_cell_content', () => {
|
||||
const data = [
|
||||
['0A', 'AABBCC', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
paddingLeft: 3
|
||||
},
|
||||
1: {
|
||||
paddingRight: 3,
|
||||
width: 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔══════╤══════╤════╗
|
||||
║ 0A │ AA │ 0C ║
|
||||
║ │ BB │ ║
|
||||
║ │ CC │ ║
|
||||
╟──────┼──────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟──────┼──────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚══════╧══════╧════╝
|
||||
`);
|
||||
});
|
||||
});
|
92
node_modules/table/test/README/usage/predefined_border_templates.js
generated
vendored
Normal file
92
node_modules/table/test/README/usage/predefined_border_templates.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
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');
|
||||
});
|
||||
});
|
56
node_modules/table/test/README/usage/streaming.js
generated
vendored
Normal file
56
node_modules/table/test/README/usage/streaming.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import {
|
||||
createStream
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
describe('process.stdout.write', () => {
|
||||
let processStdoutWriteBuffer;
|
||||
|
||||
/**
|
||||
* @var {Function} Reference to the original process.stdout.write function.
|
||||
*/
|
||||
const processStdoutWrite = process.stdout.write;
|
||||
|
||||
/**
|
||||
* @returns {undefined}
|
||||
*/
|
||||
const overwriteProcessStdoutWrite = () => {
|
||||
processStdoutWriteBuffer = '';
|
||||
|
||||
process.stdout.write = (text) => {
|
||||
processStdoutWriteBuffer += text;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
const resetProcessStdoudWrite = () => {
|
||||
process.stdout.write = processStdoutWrite;
|
||||
|
||||
return processStdoutWriteBuffer;
|
||||
};
|
||||
|
||||
it('streaming', () => {
|
||||
const config = {
|
||||
columnCount: 3,
|
||||
columnDefault: {
|
||||
width: 2
|
||||
}
|
||||
};
|
||||
|
||||
const stream = createStream(config);
|
||||
|
||||
overwriteProcessStdoutWrite();
|
||||
|
||||
stream.write(['0A', '0B', '0C']);
|
||||
stream.write(['1A', '1B', '1C']);
|
||||
stream.write(['2A', '2B', '2C']);
|
||||
|
||||
const output = resetProcessStdoudWrite();
|
||||
|
||||
expectTable(output + '\n', '╔════╤════╤════╗\n║ 0A │ 0B │ 0C ║\n╚════╧════╧════╝\r\u001b[K╟────┼────┼────╢\n║ 1A │ 1B │ 1C ║\n╚════╧════╧════╝\r\u001b[K╟────┼────┼────╢\n║ 2A │ 2B │ 2C ║\n╚════╧════╧════╝');
|
||||
});
|
||||
});
|
||||
});
|
34
node_modules/table/test/README/usage/text_truncating.js
generated
vendored
Normal file
34
node_modules/table/test/README/usage/text_truncating.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('text_truncating', () => {
|
||||
const data = [
|
||||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
truncate: 100,
|
||||
width: 20
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔══════════════════════╗
|
||||
║ Lorem ipsum dolor si ║
|
||||
║ t amet, consectetur ║
|
||||
║ adipiscing elit. Pha ║
|
||||
║ sellus pulvinar nibh ║
|
||||
║ sed mauris conva... ║
|
||||
╚══════════════════════╝
|
||||
`);
|
||||
});
|
||||
});
|
69
node_modules/table/test/README/usage/text_wrapping.js
generated
vendored
Normal file
69
node_modules/table/test/README/usage/text_wrapping.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('text_wrapping (no wrap word)', () => {
|
||||
const data = [
|
||||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 20
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔══════════════════════╗
|
||||
║ Lorem ipsum dolor si ║
|
||||
║ t amet, consectetur ║
|
||||
║ adipiscing elit. Pha ║
|
||||
║ sellus pulvinar nibh ║
|
||||
║ sed mauris convallis ║
|
||||
║ dapibus. Nunc venena ║
|
||||
║ tis tempus nulla sit ║
|
||||
║ amet viverra. ║
|
||||
╚══════════════════════╝
|
||||
`);
|
||||
});
|
||||
|
||||
it('text_wrapping (wrap word)', () => {
|
||||
const data = [
|
||||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 20,
|
||||
wrapWord: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔══════════════════════╗
|
||||
║ Lorem ipsum dolor ║
|
||||
║ sit amet, ║
|
||||
║ consectetur ║
|
||||
║ adipiscing elit. ║
|
||||
║ Phasellus pulvinar ║
|
||||
║ nibh sed mauris ║
|
||||
║ convallis dapibus. ║
|
||||
║ Nunc venenatis ║
|
||||
║ tempus nulla sit ║
|
||||
║ amet viverra. ║
|
||||
╚══════════════════════╝
|
||||
`);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user