mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
Merge pull request #23984 from cghawthorne/master
tape: Add support for custom Error subclasses in throws
This commit is contained in:
4
types/tape/index.d.ts
vendored
4
types/tape/index.d.ts
vendored
@@ -193,13 +193,13 @@ declare namespace tape {
|
||||
* expected, if present, must be a RegExp or Function, which is used to test the exception object.
|
||||
*/
|
||||
throws(fn: () => void, msg?: string): void;
|
||||
throws(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void;
|
||||
throws(fn: () => void, exceptionExpected: RegExp | Function, msg?: string): void;
|
||||
|
||||
/**
|
||||
* Assert that the function call fn() does not throw an exception.
|
||||
*/
|
||||
doesNotThrow(fn: () => void, msg?: string): void;
|
||||
doesNotThrow(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void;
|
||||
doesNotThrow(fn: () => void, exceptionExpected: RegExp | Function, msg?: string): void;
|
||||
|
||||
/**
|
||||
* Print a message without breaking the tap output.
|
||||
|
||||
@@ -28,6 +28,12 @@ rs = tape.createStream(sopts);
|
||||
var htest: typeof tape;
|
||||
htest = tape.createHarness();
|
||||
|
||||
class CustomException extends Error {
|
||||
constructor(message?: string) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tape(name, (test: tape.Test) => {
|
||||
|
||||
@@ -146,11 +152,15 @@ tape(name, (test: tape.Test) => {
|
||||
test.throws(fn, msg);
|
||||
test.throws(fn, exceptionExpected);
|
||||
test.throws(fn, exceptionExpected, msg);
|
||||
test.throws(fn, CustomException);
|
||||
test.throws(fn, CustomException, msg);
|
||||
|
||||
test.doesNotThrow(fn);
|
||||
test.doesNotThrow(fn, msg);
|
||||
test.doesNotThrow(fn, exceptionExpected);
|
||||
test.doesNotThrow(fn, exceptionExpected, msg);
|
||||
test.doesNotThrow(fn, CustomException);
|
||||
test.doesNotThrow(fn, CustomException, msg);
|
||||
|
||||
test.test(name, (st) => {
|
||||
t = st;
|
||||
|
||||
Reference in New Issue
Block a user