Skip to content

Commit

Permalink
Merge pull request #398 from nover/master
Browse files Browse the repository at this point in the history
Document will-throw-a assertions for functions that take input
  • Loading branch information
papandreou committed May 22, 2017
2 parents 36b7f9c + 0bf76b9 commit 0daf53f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions documentation/assertions/function/to-throw-a.md
Expand Up @@ -35,3 +35,15 @@ expected function willNotThrow() {} to throw a RangeError
expected function willNotThrow() {} to throw
did not throw
```

To test functions that require input wrap the function invocation in an anonymous function

```javascript
function willThrow(input) {
if(input) throw new SyntaxError('The error message');
return input;
}
expect(function() {
willThrow('input.here')
}, 'to throw a', SyntaxError);
```

0 comments on commit 0daf53f

Please sign in to comment.