0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
denoland-deno/std/node/_fs/_fs_exists_test.ts
Bartek Iwańczuk 8feb30e325
BREAKING: remove overload of Deno.test() (#4951)
This commit removes overload of Deno.test() that accepted named
function.
2020-04-28 12:33:09 +02:00

28 lines
922 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";
const { test } = 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);
});
test("existsSyncFile", function () {
const tmpFilePath = Deno.makeTempFileSync();
assertEquals(existsSync(tmpFilePath), true);
Deno.removeSync(tmpFilePath);
assertEquals(existsSync("./notAvailable.txt"), false);
});