summaryrefslogtreecommitdiff
path: root/fs/exists_test.ts
blob: 3d781108e17505e2d32a1daaa63b7a27515d2bff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts";
import { exists, existsSync } from "./exists.ts";
import * as path from "./path/mod.ts";

const testdataDir = path.resolve("fs", "testdata");

test(async function existsFile() {
  assertEquals(
    await exists(path.join(testdataDir, "not_exist_file.ts")),
    false
  );
  assertEquals(await existsSync(path.join(testdataDir, "0.ts")), true);
});

test(function existsFileSync() {
  assertEquals(existsSync(path.join(testdataDir, "not_exist_file.ts")), false);
  assertEquals(existsSync(path.join(testdataDir, "0.ts")), true);
});

test(async function existsDirectory() {
  assertEquals(
    await exists(path.join(testdataDir, "not_exist_directory")),
    false
  );
  assertEquals(existsSync(testdataDir), true);
});

test(function existsDirectorySync() {
  assertEquals(
    existsSync(path.join(testdataDir, "not_exist_directory")),
    false
  );
  assertEquals(existsSync(testdataDir), true);
});