mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
17 lines
568 B
TypeScript
17 lines
568 B
TypeScript
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
import { assertEquals, assertThrowsAsync } from "../testing/asserts.ts";
|
|
import { deferred } from "./deferred.ts";
|
|
|
|
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>();
|
|
d.reject(new Error("A deno error 🦕"));
|
|
await assertThrowsAsync(async () => {
|
|
await d;
|
|
});
|
|
});
|