Skip to content

Commit

Permalink
test: throw for unexpected config error
Browse files Browse the repository at this point in the history
  • Loading branch information
saintsebastian committed Nov 5, 2017
1 parent af2e9a9 commit 737dd74
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions tests/unit/test.program.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,18 +536,19 @@ describe('program.main', () => {
})
.then(makeSureItFails())
.catch((error) => {
if (!(error instanceof UsageError)) {
const {capturedMessages} = consoleStream;
consoleStream.stopCapturing();

assert.match(error.message, /some error/);
assert.ok(
capturedMessages.some(
(message) => message.match(/some error/)
));
sinon.assert.notCalled(fakeApplyConfigToArgv);
sinon.assert.notCalled(fakeProcess.exit);
const {capturedMessages} = consoleStream;
consoleStream.stopCapturing();

if (error instanceof UsageError) {
throw error;
}

assert.match(error.message, /some error/);
assert.ok(capturedMessages.some(
(message) => message.match(/some error/)
));
sinon.assert.notCalled(fakeApplyConfigToArgv);
sinon.assert.notCalled(fakeProcess.exit);
});
});

Expand Down Expand Up @@ -619,17 +620,18 @@ describe('program.main', () => {
})
.then(makeSureItFails())
.catch((error) => {
if (!(error instanceof UsageError)) {
const {capturedMessages} = consoleStream;
consoleStream.stopCapturing();

assert.match(error.message, /some error/);
assert.ok(
capturedMessages.some(
(message) => message.match(/some error/)
));
sinon.assert.notCalled(fakeProcess.exit);
const {capturedMessages} = consoleStream;
consoleStream.stopCapturing();

if (error instanceof UsageError) {
throw error;
}

assert.match(error.message, /some error/);
assert.ok(capturedMessages.some(
(message) => message.match(/some error/)
));
sinon.assert.notCalled(fakeProcess.exit);
});
});
});
Expand Down

0 comments on commit 737dd74

Please sign in to comment.