mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-26 10:14:26 +08:00
Add typings for reject/rejects from code 5.0.0
Documentation: > * [`await reject([type], [message])`][artm] > > Asserts that the `Promise` reference value rejects with an exception > when called [artm]: https://github.com/hapijs/code/blob/v5.0.0/API.md#await-rejecttype-message
This commit is contained in:
@@ -159,3 +159,11 @@ expect<number[]>(foo).to.equal([]);
|
||||
const bar = Object.create(null);
|
||||
settings.comparePrototypes = false;
|
||||
expect(bar).to.equal({});
|
||||
|
||||
const rejection = Promise.reject(new Error('Oh no!'));
|
||||
/* await */ expect(rejection).to.reject('Oh no!');
|
||||
/* await */ expect(rejection).rejects('Oh no!');
|
||||
|
||||
const typedRejection = Promise.reject(new CustomError('Oh no!'));
|
||||
/* await */ expect(typedRejection).to.reject(CustomError, 'Oh no!');
|
||||
/* await */ expect(typedRejection).rejects(CustomError, 'Oh no!');
|
||||
|
||||
4
types/code/index.d.ts
vendored
4
types/code/index.d.ts
vendored
@@ -160,6 +160,10 @@ export interface Values<T> {
|
||||
match(regex: RegExp): AssertionChain<T>;
|
||||
/** Asserts that the reference value's toString() representation matches the provided regular expression. */
|
||||
matches(regex: RegExp): AssertionChain<T>;
|
||||
/** Asserts that the Promise reference value rejects with an exception when called */
|
||||
reject(type?: any, message?: string | RegExp): AssertionChain<T>;
|
||||
/** Asserts that the Promise reference value rejects with an exception when called */
|
||||
rejects(type?: any, message?: string | RegExp): AssertionChain<T>;
|
||||
/** Asserts that the reference value satisfies the provided validator function. */
|
||||
satisfy(validator: (value: T) => boolean): AssertionChain<T>;
|
||||
/** Asserts that the reference value satisfies the provided validator function. */
|
||||
|
||||
Reference in New Issue
Block a user