-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(testing): allow assertions in chai retry to have signature and be…
… nested (#602)
- Loading branch information
Showing
4 changed files
with
67 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
type PromisifiedType<T> = Promisify<T> & PromiseLike<any>; | ||
|
||
// Helper type to convert a type T into a Promise-like version of itself | ||
export type Promisify<T> = { | ||
[Key in keyof T]: T[Key] extends T | ||
? Promisify<T[Key]> & PromiseLike<any> | ||
: T[Key] extends (...args: any) => any | ||
? (...args: Parameters<T[Key]>) => Promisify<ReturnType<T[Key]>> & PromiseLike<any> | ||
: Promisify<T[Key]> & PromiseLike<any>; | ||
type Promisify<T> = { | ||
[Key in keyof T]: T[Key] extends (...args: any) => any | ||
? keyof T[Key] extends never | ||
? (...args: Parameters<T[Key]>) => PromisifiedType<ReturnType<T[Key]>> | ||
: PromisifiedType<T[Key]> & { (...args: Parameters<T[Key]>): PromisifiedType<ReturnType<T[Key]>> } | ||
: PromisifiedType<T[Key]>; | ||
}; | ||
|
||
export type PromiseLikeAssertion = Promisify<Chai.Assertion> & PromiseLike<void>; | ||
export type PromiseLikeAssertion<T extends Chai.Assertion = Chai.Assertion> = Promisify<T> & PromiseLike<void>; |