diff options
Diffstat (limited to 'cli/tests/unit/globals_test.ts')
-rw-r--r-- | cli/tests/unit/globals_test.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cli/tests/unit/globals_test.ts b/cli/tests/unit/globals_test.ts index e5ff2cc8e..b47e83cfd 100644 --- a/cli/tests/unit/globals_test.ts +++ b/cli/tests/unit/globals_test.ts @@ -153,3 +153,20 @@ Deno.test(async function promiseWithResolvers() { await assertRejects(() => promise, Error, "boom!"); } }); + +Deno.test(async function arrayFromAsync() { + // Taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync#examples + // Thank you. + const asyncIterable = (async function* () { + for (let i = 0; i < 5; i++) { + await new Promise((resolve) => setTimeout(resolve, 10 * i)); + yield i; + } + })(); + + const a = await Array.fromAsync(asyncIterable); + assertEquals(a, [0, 1, 2, 3, 4]); + + const b = await Array.fromAsync(new Map([[1, 2], [3, 4]])); + assertEquals(b, [[1, 2], [3, 4]]); +}); |