-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dom Harrington
committed
May 8, 2018
1 parent
0441255
commit 5c40ec6
Showing
3 changed files
with
36 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,33 @@ | ||
const assert = require('assert'); | ||
const minimist = require('minimist'); | ||
|
||
const cli = require('../cli'); | ||
const { version } = require('../package.json'); | ||
|
||
describe('cli', () => { | ||
let error; | ||
beforeAll(() => { | ||
error = { console }; | ||
}); | ||
|
||
afterAll(() => { | ||
console.error = error; | ||
}); | ||
|
||
it('command not found', done => | ||
cli('notARealCommand').catch(e => { | ||
assert.equal(e.message.includes('Command not found'), true) | ||
return done(); | ||
})); | ||
|
||
describe('--version', () => { | ||
it('should return version from package.json', () => | ||
cli('', [], minimist(['--version'])).then(v => assert.equal(v, version))); | ||
|
||
// This is necessary because we use --version for other commands like `docs` | ||
it('should only return version if no command', () => | ||
cli('no-such-command', [], minimist(['--version'])).then(() => { | ||
throw new Error('Should not get here'); | ||
}).catch(() => { | ||
// This can be ignored as it's just going to be | ||
// a command not found error | ||
})); | ||
}); | ||
|
||
describe('--help', () => { | ||
it('should print help and not error', () => | ||
cli('', [], minimist(['--help'])) | ||
); | ||
}); | ||
}); |