From 80a16193eadc1d504106db2a204f4e7ff25d7579 Mon Sep 17 00:00:00 2001 From: laconbass Date: Thu, 5 Dec 2013 07:57:26 +0100 Subject: [PATCH 1/2] update assertThrows, fixes #220 Given a constructor as function, try to get the error name from its prototype or itself before relying on the old behaviour. Closes #220 --- lib/chai/core/assertions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index d08a4205c..4e796749a 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -618,7 +618,7 @@ module.exports = function (chai, _) { * * Can also be used in conjunction with `length` to * assert a length range. The benefit being a - * more informative error message than if the length + * more informative error message than if the lengtht * was supplied directly. * * expect('foo').to.have.length.within(2,4); @@ -1026,7 +1026,7 @@ module.exports = function (chai, _) { constructor = null; errMsg = null; } else if (typeof constructor === 'function') { - name = (new constructor()).name; + name = constructor.prototype.name || constructor.name || (new constructor()).name; } else { constructor = null; } From acf96c08cf606b4c9197c7ff93733ab0c851656c Mon Sep 17 00:00:00 2001 From: laconbass Date: Thu, 5 Dec 2013 08:02:02 +0100 Subject: [PATCH 2/2] Deleted a character incorrectly typed --- lib/chai/core/assertions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index 4e796749a..3549a8924 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -618,7 +618,7 @@ module.exports = function (chai, _) { * * Can also be used in conjunction with `length` to * assert a length range. The benefit being a - * more informative error message than if the lengtht + * more informative error message than if the length * was supplied directly. * * expect('foo').to.have.length.within(2,4);