Fix definitions of “throw” and “throwError”

This commit is contained in:
Lukas Spieß
2017-08-16 17:03:01 +02:00
parent c5d04fb2d5
commit 2209c748ea
2 changed files with 14 additions and 2 deletions

View File

@@ -91,7 +91,7 @@ interface ShouldAssertion {
enumerables(...properties: string[]): ShouldAssertion;
startWith(expected: string, message?: any): ShouldAssertion;
endWith(expected: string, message?: any): ShouldAssertion;
throw(message?: any): ShouldAssertion;
throw(message?: any, properties?: Object): ShouldAssertion;
//promises
eventually: ShouldAssertion;
@@ -137,7 +137,7 @@ interface ShouldAssertion {
deepEqual(expected: any, description?: string): ShouldAssertion;
exactly(expected: any, description?: string): ShouldAssertion;
instanceOf(constructor: Function, description?: string): ShouldAssertion;
throwError(message?: any): ShouldAssertion;
throwError(message?: any, properties?: Object): ShouldAssertion;
lengthOf(n: number, description?: string): ShouldAssertion;
key(key: string): ShouldAssertion;
hasOwnProperty(name: string, description?: string): ShouldAssertion;

View File

@@ -243,6 +243,18 @@ spy.should.have.threw("ReferenceError");
throw new Error('failed to foo');
}).should.throw(/^fail/);
(function () {
throw new Error('failed to foo');
}).should.throw(Error);
(function () {
throw new Error('failed to foo');
}).should.throw(Error, { message: 'failed to baz' });
(function () {
throw new Error('failed to foo');
}).should.throwError(Error, { message: 'failed to baz' });
(function () {
throw new Error('failed to baz');
}).should.throwError(/^fail.*/);