Skip to content

Commit

Permalink
Primitives now use valueOf in shouldGetter
Browse files Browse the repository at this point in the history
This allows the should syntax to be more resilient when
dealing with modified primitive constructors which
may occur more frequently with ES6 to ES5 transpilation.
  • Loading branch information
dcneiner committed Feb 24, 2015
1 parent 09e17b9 commit ef04544
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/chai/interface/should.js
Expand Up @@ -10,10 +10,8 @@ module.exports = function (chai, util) {
function loadShould () {
// explicitly define this method as function as to have it's name to include as `ssfi`
function shouldGetter() {
if (this instanceof String || this instanceof Number) {
return new Assertion(this.constructor(this), null, shouldGetter);
} else if (this instanceof Boolean) {
return new Assertion(this == true, null, shouldGetter);
if (this instanceof String || this instanceof Number || this instanceof Boolean ) {
return new Assertion(this.valueOf(), null, shouldGetter);
}
return new Assertion(this, null, shouldGetter);
}
Expand Down

0 comments on commit ef04544

Please sign in to comment.