diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/os_test.ts | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/js/os_test.ts b/js/os_test.ts index 766cd1c3f..b2f511b5e 100644 --- a/js/os_test.ts +++ b/js/os_test.ts @@ -39,6 +39,26 @@ test(function osIsTTYSmoke(): void { console.log(Deno.isTTY()); }); -test(function homeDir(): void { +testPerm({ env: true }, function homeDir(): void { assertNotEquals(Deno.homeDir(), ""); }); + +testPerm({ env: false }, function homeDirPerm(): void { + let caughtError = false; + try { + Deno.homeDir(); + } catch (err) { + caughtError = true; + assertEquals(err.kind, Deno.ErrorKind.PermissionDenied); + assertEquals(err.name, "PermissionDenied"); + } + assert(caughtError); +}); + +testPerm({ env: true }, function execPath(): void { + assertNotEquals(Deno.execPath, ""); +}); + +testPerm({ env: false }, function execPathPerm(): void { + assertEquals(Deno.execPath, ""); +}); |