From f55b22e195ff0dfaf117aaef2a0fcc51fe0058c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 29 Feb 2020 18:45:47 +0100 Subject: add assertResources sanitizer to cli/js/ unit tests (#4161) --- cli/js/workers_test.ts | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'cli/js/workers_test.ts') diff --git a/cli/js/workers_test.ts b/cli/js/workers_test.ts index 7dbd316ec..5b8b1ef97 100644 --- a/cli/js/workers_test.ts +++ b/cli/js/workers_test.ts @@ -1,23 +1,11 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { test, testPerm, assert, assertEquals } from "./test_util.ts"; - -export interface ResolvableMethods { - resolve: (value?: T | PromiseLike) => void; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - reject: (reason?: any) => void; -} - -export type Resolvable = Promise & ResolvableMethods; - -export function createResolvable(): Resolvable { - let methods: ResolvableMethods; - const promise = new Promise((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; -} +import { + test, + testPerm, + assert, + assertEquals, + createResolvable +} from "./test_util.ts"; test(async function workersBasic(): Promise { const promise = createResolvable(); -- cgit v1.2.3