2019-03-11 13:14:26 -04:00
|
|
|
// 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");
|
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
test(async function existsFile(): Promise<void> {
|
2019-03-11 13:14:26 -04:00
|
|
|
assertEquals(
|
|
|
|
await exists(path.join(testdataDir, "not_exist_file.ts")),
|
|
|
|
false
|
|
|
|
);
|
|
|
|
assertEquals(await existsSync(path.join(testdataDir, "0.ts")), true);
|
|
|
|
});
|
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
test(function existsFileSync(): void {
|
2019-03-11 13:14:26 -04:00
|
|
|
assertEquals(existsSync(path.join(testdataDir, "not_exist_file.ts")), false);
|
|
|
|
assertEquals(existsSync(path.join(testdataDir, "0.ts")), true);
|
|
|
|
});
|
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
test(async function existsDirectory(): Promise<void> {
|
2019-03-11 13:14:26 -04:00
|
|
|
assertEquals(
|
|
|
|
await exists(path.join(testdataDir, "not_exist_directory")),
|
|
|
|
false
|
|
|
|
);
|
|
|
|
assertEquals(existsSync(testdataDir), true);
|
|
|
|
});
|
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
test(function existsDirectorySync(): void {
|
2019-03-11 13:14:26 -04:00
|
|
|
assertEquals(
|
|
|
|
existsSync(path.join(testdataDir, "not_exist_directory")),
|
|
|
|
false
|
|
|
|
);
|
|
|
|
assertEquals(existsSync(testdataDir), true);
|
|
|
|
});
|
2019-03-18 12:34:54 -04:00
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
test(function existsLinkSync(): void {
|
2019-06-19 00:22:01 -04:00
|
|
|
// TODO(axetroy): generate link file use Deno api instead of set a link file
|
|
|
|
// in repository
|
2019-03-18 12:34:54 -04:00
|
|
|
assertEquals(existsSync(path.join(testdataDir, "0-link.ts")), true);
|
|
|
|
});
|
|
|
|
|
2019-04-24 07:41:23 -04:00
|
|
|
test(async function existsLink(): Promise<void> {
|
2019-06-19 00:22:01 -04:00
|
|
|
// TODO(axetroy): generate link file use Deno api instead of set a link file
|
|
|
|
// in repository
|
2019-03-18 12:34:54 -04:00
|
|
|
assertEquals(await exists(path.join(testdataDir, "0-link.ts")), true);
|
|
|
|
});
|