fix instanceof rethrow test

This commit is contained in:
Aleksey Shvayka 2017-09-06 22:19:10 +03:00
parent 6586e2dcbe
commit d4fde80a3c
3 changed files with 3 additions and 26 deletions

View file

@ -180,19 +180,12 @@ describe('assert', function () {
assert.instanceOf(new Foo(), undefined);
}, "The instanceof assertion needs a constructor but undefined was given.");
var expectedError;
try {
t instanceof Thing;
} catch (err) {
errMsg = '[object Object] instanceof function Thing(){} failed: ' + err.message + '.';
}
err(function(){
function Thing(){};
var t = new Thing();
Thing.prototype = 1337;
assert.instanceOf(t, Thing);
}, expectedError, true);
}, 'The instanceof assertion needs a constructor but function was given.', true);
if (typeof Symbol !== 'undefined' && typeof Symbol.hasInstance !== 'undefined') {
err(function(){

View file

@ -413,20 +413,12 @@ describe('expect', function () {
expect(new Foo()).to.an.instanceof(undefined);
}, "The instanceof assertion needs a constructor but undefined was given.");
// Different browsers may have different error messages
var expectedError;
try {
t instanceof Thing;
} catch (err) {
errMsg = '[object Object] instanceof function Thing(){} failed: ' + err.message + '.';
}
err(function(){
function Thing(){};
var t = new Thing();
Thing.prototype = 1337;
expect(t).to.an.instanceof(Thing);
}, expectedError, true)
}, 'The instanceof assertion needs a constructor but function was given.', true)
if (typeof Symbol !== 'undefined' && typeof Symbol.hasInstance !== 'undefined') {
err(function(){

View file

@ -455,20 +455,12 @@ describe('should', function() {
new Foo().should.be.an.instanceof(undefined);
}, "The instanceof assertion needs a constructor but undefined was given.");
// Different browsers may have different error messages
var expectedError;
try {
t instanceof Thing;
} catch (err) {
errMsg = '[object Object] instanceof function Thing(){} failed: ' + err.message + '.';
}
err(function(){
function Thing(){};
var t = new Thing();
Thing.prototype = 1337;
t.should.be.an.instanceof(Thing);
}, expectedError, true);
}, 'The instanceof assertion needs a constructor but function was given.', true);
if (typeof Symbol !== 'undefined' && typeof Symbol.hasInstance !== 'undefined') {
err(function(){