diff options
| author | River <22485304+actual-size@users.noreply.github.com> | 2020-06-12 02:36:20 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-11 12:36:20 -0400 |
| commit | 818a8010928cb8cef0b7043bd881c8cdce9b6efc (patch) | |
| tree | 1502e74c9eb01901df8da118257d60d4f962b0e4 /cli/tests/unit/read_dir_test.ts | |
| parent | 813210d4337bf6e174f1da1f1a6c6fb9b073afa2 (diff) | |
feat: URL support in Deno filesystem methods (#5990)
Diffstat (limited to 'cli/tests/unit/read_dir_test.ts')
| -rw-r--r-- | cli/tests/unit/read_dir_test.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/cli/tests/unit/read_dir_test.ts b/cli/tests/unit/read_dir_test.ts index 79e2a1507..d9a5244c7 100644 --- a/cli/tests/unit/read_dir_test.ts +++ b/cli/tests/unit/read_dir_test.ts @@ -1,5 +1,10 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { unitTest, assert, assertEquals } from "./test_util.ts"; +import { + unitTest, + assert, + assertEquals, + pathToAbsoluteFileUrl, +} from "./test_util.ts"; function assertSameContent(files: Deno.DirEntry[]): void { let counter = 0; @@ -19,6 +24,11 @@ unitTest({ perms: { read: true } }, function readDirSyncSuccess(): void { assertSameContent(files); }); +unitTest({ perms: { read: true } }, function readDirSyncWithUrl(): void { + const files = [...Deno.readDirSync(pathToAbsoluteFileUrl("cli/tests"))]; + assertSameContent(files); +}); + unitTest({ perms: { read: false } }, function readDirSyncPerm(): void { let caughtError = false; try { @@ -68,6 +78,18 @@ unitTest({ perms: { read: true } }, async function readDirSuccess(): Promise< assertSameContent(files); }); +unitTest({ perms: { read: true } }, async function readDirWithUrl(): Promise< + void +> { + const files = []; + for await (const dirEntry of Deno.readDir( + pathToAbsoluteFileUrl("cli/tests") + )) { + files.push(dirEntry); + } + assertSameContent(files); +}); + unitTest({ perms: { read: false } }, async function readDirPerm(): Promise< void > { |
