mirror of
https://github.com/denoland/deno.git
synced 2024-12-04 17:18:23 -05:00
25 lines
907 B
TypeScript
25 lines
907 B
TypeScript
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
import { assertEquals } from "../../testing/asserts.ts";
|
|
import { exists, existsSync } from "./_fs_exists.ts";
|
|
|
|
Deno.test("existsFile", async function () {
|
|
const availableFile = await new Promise((resolve) => {
|
|
const tmpFilePath = Deno.makeTempFileSync();
|
|
exists(tmpFilePath, (exists: boolean) => {
|
|
Deno.removeSync(tmpFilePath);
|
|
resolve(exists);
|
|
});
|
|
});
|
|
const notAvailableFile = await new Promise((resolve) => {
|
|
exists("./notAvailable.txt", (exists: boolean) => resolve(exists));
|
|
});
|
|
assertEquals(availableFile, true);
|
|
assertEquals(notAvailableFile, false);
|
|
});
|
|
|
|
Deno.test("existsSyncFile", function () {
|
|
const tmpFilePath = Deno.makeTempFileSync();
|
|
assertEquals(existsSync(tmpFilePath), true);
|
|
Deno.removeSync(tmpFilePath);
|
|
assertEquals(existsSync("./notAvailable.txt"), false);
|
|
});
|