summaryrefslogtreecommitdiff
path: root/std/node/_fs/_fs_exists_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/node/_fs/_fs_exists_test.ts')
-rw-r--r--std/node/_fs/_fs_exists_test.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/std/node/_fs/_fs_exists_test.ts b/std/node/_fs/_fs_exists_test.ts
new file mode 100644
index 000000000..aaf26a0e7
--- /dev/null
+++ b/std/node/_fs/_fs_exists_test.ts
@@ -0,0 +1,26 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
+import { assertEquals } from "../../testing/asserts.ts";
+import { exists, existsSync } from "./_fs_exists.ts";
+
+const { test } = Deno;
+
+test(async function existsFile() {
+ const availableFile = await new Promise(async (resolve) => {
+ const tmpFilePath = await Deno.makeTempFile();
+ exists(tmpFilePath, (exists: boolean) => resolve(exists));
+ Deno.remove(tmpFilePath);
+ });
+ const notAvailableFile = await new Promise((resolve) => {
+ exists("./notAvailable.txt", (exists: boolean) => resolve(exists));
+ });
+ assertEquals(availableFile, true);
+ assertEquals(notAvailableFile, false);
+});
+
+test(function existsSyncFile() {
+ const tmpFilePath = Deno.makeTempFileSync();
+ assertEquals(existsSync(tmpFilePath), true);
+ Deno.removeSync(tmpFilePath);
+ assertEquals(existsSync("./notAvailable.txt"), false);
+});