diff options
Diffstat (limited to 'cli/js/tests/read_dir_test.ts')
-rw-r--r-- | cli/js/tests/read_dir_test.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/cli/js/tests/read_dir_test.ts b/cli/js/tests/read_dir_test.ts index 95936c645..2c7f42103 100644 --- a/cli/js/tests/read_dir_test.ts +++ b/cli/js/tests/read_dir_test.ts @@ -1,14 +1,12 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { unitTest, assert, assertEquals } from "./test_util.ts"; -type FileInfo = Deno.FileInfo; - -function assertSameContent(files: FileInfo[]): void { +function assertSameContent(files: Deno.DirEntry[]): void { let counter = 0; for (const file of files) { if (file.name === "subdir") { - assert(file.isDirectory()); + assert(file.isDirectory); counter++; } @@ -22,7 +20,7 @@ function assertSameContent(files: FileInfo[]): void { } unitTest({ perms: { read: true } }, function readdirSyncSuccess(): void { - const files = Deno.readdirSync("cli/tests/"); + const files = [...Deno.readdirSync("cli/tests/")]; assertSameContent(files); }); @@ -68,7 +66,10 @@ unitTest({ perms: { read: true } }, function readdirSyncNotFound(): void { unitTest({ perms: { read: true } }, async function readdirSuccess(): Promise< void > { - const files = await Deno.readdir("cli/tests/"); + const files = []; + for await (const dirEntry of Deno.readdir("cli/tests/")) { + files.push(dirEntry); + } assertSameContent(files); }); @@ -77,7 +78,7 @@ unitTest({ perms: { read: false } }, async function readdirPerm(): Promise< > { let caughtError = false; try { - await Deno.readdir("tests/"); + await Deno.readdir("tests/")[Symbol.asyncIterator]().next(); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.PermissionDenied); |