Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
♻️ Add work around for cutom error check
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed Feb 14, 2018
1 parent 90152f0 commit d866859
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
1 change: 0 additions & 1 deletion test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,5 @@ mochaBDD();

[sinonChai, chaiAsPromised].forEach(plugin => chai.use(plugin));

global.should = chai.should();
global.sinon = sinon;
global.sandbox = sinon.sandbox.create();
35 changes: 29 additions & 6 deletions test/steps/general/3_then.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*
*/
import { getFirstQuotedString, getFirstNumber } from '../utils';
import { FileSystemError, ValidationError } from '../../../src/utils/error';

export function theErrorShouldBeInstanceOfNodesBuiltInError() {
const { testError } = this.test.ctx;
Expand All @@ -35,13 +34,29 @@ export function itShouldReturnTheResult() {
export function itShouldThrowValidationError() {
const { testFunction } = this.test.ctx;
const message = getFirstQuotedString(this.test.title);
return testFunction.should.throw(ValidationError, message);
testFunction.should.throw().and.is.instanceOf(Error);
testFunction.should
.throw()
.and.has.property('name')
.which.equal('ValidationError');
return testFunction.should
.throw()
.and.has.property('message')
.which.include(message);
}

export function itShouldThrowFileSystemError() {
const { testFunction } = this.test.ctx;
const message = getFirstQuotedString(this.test.title);
return testFunction.should.throw(FileSystemError, message);
testFunction.should.throw().and.is.instanceOf(Error);
testFunction.should
.throw()
.and.has.property('name')
.which.equal('FileSystemError');
return testFunction.should
.throw()
.and.has.property('message')
.which.include(message);
}

export function itShouldExitWithCode() {
Expand Down Expand Up @@ -82,13 +97,21 @@ export function itShouldRejectWithTheErrorMessage() {
export function itShouldRejectWithFileSystemErrorAndMessage() {
const { returnValue } = this.test.ctx;
const message = getFirstQuotedString(this.test.title);
return returnValue.should.be.rejectedWith(new FileSystemError(message));
return returnValue.should.be.rejected.then(err => {
err.should.be.instanceOf(Error);
err.should.have.property('name').which.equal('FileSystemError');
return err.should.have.property('message').which.include(message);
});
}

export function itShouldRejectWithValidationErrorAndMessage() {
const { returnValue } = this.test.ctx;
const message = getFirstQuotedString(this.test.title);
return returnValue.should.be.rejectedWith(new ValidationError(message));
return returnValue.should.be.rejected.then(err => {
err.should.be.instanceOf(Error);
err.should.have.property('name').which.equal('ValidationError');
return err.should.have.property('message').which.include(message);
});
}

export function itShouldRejectWithMessage() {
Expand Down Expand Up @@ -119,7 +142,7 @@ export function itShouldReturnFalse() {

export function itShouldReturnNull() {
const { returnValue } = this.test.ctx;
return should(returnValue).be.null;
return should.equal(returnValue, null);
}

export function itShouldReturnString() {
Expand Down
2 changes: 1 addition & 1 deletion test/steps/printing/3_then.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,6 @@ export function theReturnedTableShouldHaveARowForEachObjectWithTheObjectsValues(
values.forEach(value => row.should.include(value));
return row
.filter(value => !values.includes(value))
.forEach(value => should(value).be.undefined);
.forEach(value => should.equal(value, undefined));
});
}

0 comments on commit d866859

Please sign in to comment.