diff options
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( |