1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00
denoland-deno/std/async/deferred_test.ts

18 lines
568 B
TypeScript
Raw Normal View History

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
2020-05-15 16:59:44 -04:00
import { assertEquals, assertThrowsAsync } from "../testing/asserts.ts";
import { deferred } from "./deferred.ts";
2020-05-15 16:59:44 -04:00
Deno.test("[async] deferred: resolve", async function (): Promise<void> {
const d = deferred<string>();
d.resolve("🦕");
assertEquals(await d, "🦕");
});
Deno.test("[async] deferred: reject", async function (): Promise<void> {
const d = deferred<number>();
2020-05-15 16:59:44 -04:00
d.reject(new Error("A deno error 🦕"));
await assertThrowsAsync(async () => {
await d;
});
});