mirror of
https://github.com/denoland/deno.git
synced 2025-07-23 13:15:16 +00:00
refactor(cli/tests/unit) to use assertThrows (#6459)
This commit is contained in:
parent
6bbe52fba3
commit
87f8f99c49
28 changed files with 404 additions and 913 deletions
|
@ -1,5 +1,11 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
import { unitTest, assert, assertEquals, assertThrows } from "./test_util.ts";
|
||||
import {
|
||||
unitTest,
|
||||
assert,
|
||||
assertEquals,
|
||||
assertThrows,
|
||||
assertThrowsAsync,
|
||||
} from "./test_util.ts";
|
||||
|
||||
function assertDirectory(path: string, mode?: number): void {
|
||||
const info = Deno.lstatSync(path);
|
||||
|
@ -28,14 +34,9 @@ unitTest(
|
|||
);
|
||||
|
||||
unitTest({ perms: { write: false } }, function mkdirSyncPerm(): void {
|
||||
let err;
|
||||
try {
|
||||
assertThrows(() => {
|
||||
Deno.mkdirSync("/baddir");
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
assert(err instanceof Deno.errors.PermissionDenied);
|
||||
assertEquals(err.name, "PermissionDenied");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
});
|
||||
|
||||
unitTest(
|
||||
|
@ -57,25 +58,17 @@ unitTest(
|
|||
);
|
||||
|
||||
unitTest({ perms: { write: true } }, function mkdirErrSyncIfExists(): void {
|
||||
let err;
|
||||
try {
|
||||
assertThrows(() => {
|
||||
Deno.mkdirSync(".");
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
assert(err instanceof Deno.errors.AlreadyExists);
|
||||
}, Deno.errors.AlreadyExists);
|
||||
});
|
||||
|
||||
unitTest({ perms: { write: true } }, async function mkdirErrIfExists(): Promise<
|
||||
void
|
||||
> {
|
||||
let err;
|
||||
try {
|
||||
await assertThrowsAsync(async () => {
|
||||
await Deno.mkdir(".");
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
assert(err instanceof Deno.errors.AlreadyExists);
|
||||
}, Deno.errors.AlreadyExists);
|
||||
});
|
||||
|
||||
unitTest(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue