Skip to content

Commit

Permalink
Merge pull request #28 from perrin4869/master
Browse files Browse the repository at this point in the history
Fix compatibility with chai-as-promised with chai@4
  • Loading branch information
joshperry committed Jul 10, 2017
2 parents f82d79e + 909802d commit 4f524c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/dirty-chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
function newProperty() {
// Flag deferred assert here
defer(this, getter);
return this;
});
}
}
Expand Down Expand Up @@ -130,6 +131,7 @@
return function() {
// Getter of chainable method
defer(this, _super);
return this;
};
});
});
Expand All @@ -147,6 +149,7 @@
Assertion.overwriteProperty(property.name, function(_super) {
return function() {
defer(this, _super);
return this;
};
});
});
Expand Down Expand Up @@ -204,6 +207,7 @@
return function() {
// Getter of chainable method
defer(this, _super);
return this;
};
});
}
Expand Down
15 changes: 15 additions & 0 deletions test/dirty-chai.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var chai = requireUncached('chai');
var expect = chai.expect;
chai.should();

chai.use(require('chai-as-promised'));
chai.use(requireUncached('../lib/dirty-chai'));

function shouldFail(func, msg) {
Expand Down Expand Up @@ -137,4 +138,18 @@ describe('dirty chai', function() {
expect(stubCalled).to.be.true();
});
});

describe('compatibility with chai-as-promised', function() {
it('should pass with resolved promise', function() {
return expect(Promise.resolve(true)).to.eventually.be.true();
});

it('should pass with rejected promise', function() {
var err = new Error('foo');
err.name = 'bar';
return expect(Promise.reject(err)).to.eventually
.be.rejectedWith(Error)
.and.to.have.property('name', 'bar');
});
});
});

0 comments on commit 4f524c3

Please sign in to comment.