diff options
author | crowlKats <13135287+crowlKats@users.noreply.github.com> | 2020-11-26 17:22:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-26 17:22:36 +0100 |
commit | e6685f0f01b8a11a5eaff020f5babcfde76b3038 (patch) | |
tree | 6c6850bf7bc253f29aec97e2d221f87a2da53c50 /cli/tests/unit/test_util.ts | |
parent | 2031418a24e6df65a600349db940a555b1220088 (diff) |
refactor(cli/tests): replace createResolvable with deferred (#8507)
Diffstat (limited to 'cli/tests/unit/test_util.ts')
-rw-r--r-- | cli/tests/unit/test_util.ts | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/cli/tests/unit/test_util.ts b/cli/tests/unit/test_util.ts index 6163865de..39a1949c3 100644 --- a/cli/tests/unit/test_util.ts +++ b/cli/tests/unit/test_util.ts @@ -16,6 +16,7 @@ export { fail, unreachable, } from "../../../std/testing/asserts.ts"; +export { deferred } from "../../../std/async/deferred.ts"; export { readLines } from "../../../std/io/bufio.ts"; export { parse as parseArgs } from "../../../std/flags/mod.ts"; @@ -187,24 +188,6 @@ export function unitTest( REGISTERED_UNIT_TESTS.push(unitTestDefinition); } -export interface ResolvableMethods<T> { - resolve: (value: T | PromiseLike<T>) => void; - // deno-lint-ignore no-explicit-any - reject: (reason?: any) => void; -} - -export type Resolvable<T> = Promise<T> & ResolvableMethods<T>; - -export function createResolvable<T = void>(): Resolvable<T> { - let methods: ResolvableMethods<T>; - const promise = new Promise<T>((resolve, reject): void => { - methods = { resolve, reject }; - }); - // TypeScript doesn't know that the Promise callback occurs synchronously - // therefore use of not null assertion (`!`) - return Object.assign(promise, methods!) as Resolvable<T>; -} - const encoder = new TextEncoder(); // Replace functions with null, errors with their stack strings, and JSONify. |