Permalink
Browse files

Added tests for throwError/throwException with fn.

  • Loading branch information...
1 parent 0829d70 commit 59b3ead7b5afeadaa1e1217135dda35851e5d261 @rauchg rauchg committed Feb 4, 2012
Showing with 28 additions and 0 deletions.
  1. +28 −0 test/expect.js
View
@@ -84,6 +84,10 @@ describe('expect', function () {
a.b.c;
}
+ function itThrowsString () {
+ throw 'aaa';
+ }
+
var anonItThrows = function () {
a.b.c;
}
@@ -97,6 +101,30 @@ describe('expect', function () {
expect(itThrows).to.throwException();
expect(itWorks).to.not.throwException();
+ var subject;
+
+ expect(itThrows).to.throwException(function (e) {
+ subject = e;
+ });
+
+ expect(subject).to.be.an(Error);
+
+ var subject2;
+
+ expect(itThrowsString).to.throwException(function (str) {
+ subject2 = str;
+ });
+
+ expect(subject2).to.be('aaa');
+
+ var called = false;
+
+ expect(itWorks).to.not.throwError(function () {
+ called = true;
+ });
+
+ expect(called).to.be(false);
+
err(function () {
expect(5).to.throwException();
}, 'expected 5 to be a function');

0 comments on commit 59b3ead

Please sign in to comment.