diff options
author | Ross Weir <29697678+ross-weir@users.noreply.github.com> | 2020-10-27 23:21:32 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-27 13:21:32 +0100 |
commit | 60cd7695ef2c3769aeaf9391a2dddc6c31a9e2f5 (patch) | |
tree | 4ce9403c9e257b676de2e2a84e3cf33c5a737b27 /cli/tests/unit/mkdir_test.ts | |
parent | 5af1dcfe292eb5f8cb60e72cf8f532596739b7fc (diff) |
fix(cli): handle URL paths in Deno.mkdir() (#8140)
Diffstat (limited to 'cli/tests/unit/mkdir_test.ts')
-rw-r--r-- | cli/tests/unit/mkdir_test.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/cli/tests/unit/mkdir_test.ts b/cli/tests/unit/mkdir_test.ts index 9ab6dc4d2..f2fe168e6 100644 --- a/cli/tests/unit/mkdir_test.ts +++ b/cli/tests/unit/mkdir_test.ts @@ -4,6 +4,7 @@ import { assertEquals, assertThrows, assertThrowsAsync, + pathToAbsoluteFileUrl, unitTest, } from "./test_util.ts"; @@ -197,3 +198,33 @@ unitTest( } }, ); + +unitTest( + { perms: { read: true, write: true } }, + function mkdirSyncRelativeUrlPath(): void { + const testDir = Deno.makeTempDirSync(); + const nestedDir = testDir + "/nested"; + // Add trailing slash so base path is treated as a directory. pathToAbsoluteFileUrl removes trailing slashes. + const path = new URL("../dir", pathToAbsoluteFileUrl(nestedDir) + "/"); + + Deno.mkdirSync(nestedDir); + Deno.mkdirSync(path); + + assertDirectory(testDir + "/dir"); + }, +); + +unitTest( + { perms: { read: true, write: true } }, + async function mkdirRelativeUrlPath(): Promise<void> { + const testDir = Deno.makeTempDirSync(); + const nestedDir = testDir + "/nested"; + // Add trailing slash so base path is treated as a directory. pathToAbsoluteFileUrl removes trailing slashes. + const path = new URL("../dir", pathToAbsoluteFileUrl(nestedDir) + "/"); + + await Deno.mkdir(nestedDir); + await Deno.mkdir(path); + + assertDirectory(testDir + "/dir"); + }, +); |