diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-06-25 06:57:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-25 00:57:08 +0200 |
commit | 87f8f99c49e62c06f85bb453a7c12b32634c3bef (patch) | |
tree | e8f966f981a9f825ca1f22fe8d39642c448a9c62 /cli/tests/unit/fs_events_test.ts | |
parent | 6bbe52fba33e440e113bca423b5eae0d1f320c49 (diff) |
refactor(cli/tests/unit) to use assertThrows (#6459)
Diffstat (limited to 'cli/tests/unit/fs_events_test.ts')
-rw-r--r-- | cli/tests/unit/fs_events_test.ts | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/cli/tests/unit/fs_events_test.ts b/cli/tests/unit/fs_events_test.ts index ad8ba8502..ec146f185 100644 --- a/cli/tests/unit/fs_events_test.ts +++ b/cli/tests/unit/fs_events_test.ts @@ -1,37 +1,28 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { unitTest, assert } from "./test_util.ts"; +import { unitTest, assert, assertThrows } from "./test_util.ts"; // TODO(ry) Add more tests to specify format. unitTest({ perms: { read: false } }, function watchFsPermissions() { - let thrown = false; - try { + assertThrows(() => { Deno.watchFs("."); - } catch (err) { - assert(err instanceof Deno.errors.PermissionDenied); - thrown = true; - } - assert(thrown); + }, Deno.errors.PermissionDenied); }); unitTest({ perms: { read: true } }, function watchFsInvalidPath() { - let thrown = false; - try { - Deno.watchFs("non-existant.file"); - } catch (err) { - console.error(err); - if (Deno.build.os === "windows") { - assert( - err.message.includes( - "Input watch path is neither a file nor a directory" - ) - ); - } else { - assert(err instanceof Deno.errors.NotFound); - } - thrown = true; + if (Deno.build.os === "windows") { + assertThrows( + () => { + Deno.watchFs("non-existant.file"); + }, + Error, + "Input watch path is neither a file nor a directory" + ); + } else { + assertThrows(() => { + Deno.watchFs("non-existant.file"); + }, Deno.errors.NotFound); } - assert(thrown); }); async function getTwoEvents( |