1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-30 11:16:38 -05:00
denoland-deno/std/node/_fs/_fs_copy_test.ts

32 lines
903 B
TypeScript
Raw Normal View History

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assert } from "../../testing/asserts.ts";
import { copyFile, copyFileSync } from "./_fs_copy.ts";
import { existsSync } from "./_fs_exists.ts";
const destFile = "./destination.txt";
Deno.test({
name: "[std/node/fs] copy file",
fn: async () => {
2020-05-25 09:35:11 -04:00
const sourceFile = Deno.makeTempFileSync();
const err = await new Promise((resolve) => {
2020-05-25 09:35:11 -04:00
copyFile(sourceFile, destFile, (err?: Error | null) => resolve(err));
});
assert(!err);
assert(existsSync(destFile));
2020-05-25 09:35:11 -04:00
Deno.removeSync(sourceFile);
Deno.removeSync(destFile);
},
});
Deno.test({
name: "[std/node/fs] copy file sync",
fn: () => {
2020-05-25 09:35:11 -04:00
const sourceFile = Deno.makeTempFileSync();
copyFileSync(sourceFile, destFile);
assert(existsSync(destFile));
2020-05-25 09:35:11 -04:00
Deno.removeSync(sourceFile);
Deno.removeSync(destFile);
},
});