Skip to content

Commit

Permalink
Add tests for some getters (#1369)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn committed Oct 4, 2020
1 parent 39eadd7 commit f15900d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/command.alias.test.js
Expand Up @@ -73,3 +73,17 @@ test('when use second of aliases then action handler called', () => {
program.parse(['dir'], { from: 'user' });
expect(actionMock).toHaveBeenCalled();
});

test('when set alias then can get alias', () => {
const program = new commander.Command();
const alias = 'abcde';
program.alias(alias);
expect(program.alias()).toEqual(alias);
});

test('when set aliases then can get aliases', () => {
const program = new commander.Command();
const aliases = ['a', 'b'];
program.aliases(aliases);
expect(program.aliases()).toEqual(aliases);
});
8 changes: 8 additions & 0 deletions tests/command.description.test.js
@@ -0,0 +1,8 @@
const commander = require('../');

test('when set description then get description', () => {
const program = new commander.Command();
const description = 'abcdef';
program.description(description);
expect(program.description()).toMatch(description);
});
7 changes: 7 additions & 0 deletions tests/options.version.test.js
Expand Up @@ -165,4 +165,11 @@ describe('.version', () => {
program.parse(['node', 'test', '--version']);
}).toThrow(myVersion);
});

test('when specify version then can get version', () => {
const myVersion = '1.2.3';
const program = new commander.Command();
program.version(myVersion);
expect(program.version()).toEqual(myVersion);
});
});

0 comments on commit f15900d

Please sign in to comment.