Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for some getters #1369

Merged
merged 1 commit into from Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
});
});