forked from tj/commander.js
/
help.longestArgumentTermLength.test.js
32 lines (28 loc) · 1.19 KB
/
help.longestArgumentTermLength.test.js
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
const commander = require('../');
// These are tests of the Help class, not of the Command help.
// There is some overlap with the higher level Command tests (which predate Help).
describe('longestArgumentTermLength', () => {
test('when no arguments then returns zero', () => {
const program = new commander.Command();
const helper = new commander.Help();
expect(helper.longestArgumentTermLength(program, helper)).toEqual(0);
});
test('when has argument description then returns argument length', () => {
const program = new commander.Command();
program.arguments('<wonder>');
program.description('dummy', { wonder: 'wonder description' });
const helper = new commander.Help();
expect(helper.longestArgumentTermLength(program, helper)).toEqual('wonder'.length);
});
test('when has multiple argument descriptions then returns longest', () => {
const program = new commander.Command();
program.arguments('<alpha> <longest> <beta>');
program.description('dummy', {
alpha: 'x',
longest: 'x',
beta: 'x'
});
const helper = new commander.Help();
expect(helper.longestArgumentTermLength(program, helper)).toEqual('longest'.length);
});
});