Skip to content

Commit

Permalink
fix instanceof rethrow test
Browse files Browse the repository at this point in the history
  • Loading branch information
shvaikalesh committed Sep 6, 2017
1 parent 6586e2d commit d4fde80
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 26 deletions.
9 changes: 1 addition & 8 deletions test/assert.js
Expand Up @@ -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(){
Expand Down
10 changes: 1 addition & 9 deletions test/expect.js
Expand Up @@ -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(){
Expand Down
10 changes: 1 addition & 9 deletions test/should.js
Expand Up @@ -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(){
Expand Down

0 comments on commit d4fde80

Please sign in to comment.