summaryrefslogtreecommitdiff
path: root/cli/tests/unit/read_dir_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit/read_dir_test.ts')
-rw-r--r--cli/tests/unit/read_dir_test.ts24
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
> {