forked from mattallty/Caporal.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuggest.js
33 lines (26 loc) · 887 Bytes
/
suggest.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
33
"use strict";
/* global Program, logger, should, makeArgv, sinon */
const program = new Program();
const stripColor = require('chalk').stripColor;
program
.logger(logger)
.version('1.0.0');
describe('Passing --foo', () => {
it(`should suggest --foor and --afoo and --footx`, () => {
program
.option('--foor <foor>')
.option('--afoo <afoo>')
.option('--footx <footx>')
.action(function() {});
const error = sinon.stub(program, "fatalError", function(err) {
should(err.name).eql('UnknownOptionError');
should(stripColor(err.originalMessage)).containEql('foor');
should(stripColor(err.originalMessage)).containEql('afoo');
should(stripColor(err.originalMessage)).containEql('footx');
});
program.parse(makeArgv('--foo'));
should(error.callCount).be.eql(1);
error.restore();
program.reset();
});
});