Permalink
Browse files

Fix compatibility with chai-as-promised with chai@4

  • Loading branch information...
perrin4869 committed Jun 30, 2017
1 parent f82d79e commit 909802dc41c9a2b378a43f4ab2506215d34c9245
Showing with 19 additions and 0 deletions.
  1. +4 −0 lib/dirty-chai.js
  2. +15 −0 test/dirty-chai.spec.js
View
@@ -70,6 +70,7 @@
function newProperty() {
// Flag deferred assert here
defer(this, getter);
return this;
});
}
}
@@ -130,6 +131,7 @@
return function() {
// Getter of chainable method
defer(this, _super);
return this;
};
});
});
@@ -147,6 +149,7 @@
Assertion.overwriteProperty(property.name, function(_super) {
return function() {
defer(this, _super);
return this;
};
});
});
@@ -204,6 +207,7 @@
return function() {
// Getter of chainable method
defer(this, _super);
return this;
};
});
}
View
@@ -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) {
@@ -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 909802d

Please sign in to comment.