From eec6ed601e920a1a17975849d829e058c95a267c Mon Sep 17 00:00:00 2001 From: Henry Zhuang Date: Sat, 16 May 2020 06:59:44 +1000 Subject: [PATCH] improve deferred test (denoland/deno#5459) --- async/deferred_test.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/async/deferred_test.ts b/async/deferred_test.ts index 83c317853..c411885d0 100644 --- a/async/deferred_test.ts +++ b/async/deferred_test.ts @@ -1,8 +1,17 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +import { assertEquals, assertThrowsAsync } from "../testing/asserts.ts"; import { deferred } from "./deferred.ts"; -Deno.test("[async] deferred", function (): Promise { - const d = deferred(); - d.resolve(12); - return Promise.resolve(); +Deno.test("[async] deferred: resolve", async function (): Promise { + const d = deferred(); + d.resolve("🦕"); + assertEquals(await d, "🦕"); +}); + +Deno.test("[async] deferred: reject", async function (): Promise { + const d = deferred(); + d.reject(new Error("A deno error 🦕")); + await assertThrowsAsync(async () => { + await d; + }); });