mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
34 lines
921 B
TypeScript
34 lines
921 B
TypeScript
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||
|
import { copyFile, copyFileSync } from "./_fs_copy.ts";
|
||
|
import { existsSync } from "./_fs_exists.ts";
|
||
|
|
||
|
import { assert } from "../../testing/asserts.ts";
|
||
|
const { test } = Deno;
|
||
|
|
||
|
const destFile = "./destination.txt";
|
||
|
|
||
|
test({
|
||
|
name: "[std/node/fs] copy file",
|
||
|
fn: async () => {
|
||
|
const srouceFile = Deno.makeTempFileSync();
|
||
|
const err = await new Promise((resolve) => {
|
||
|
copyFile(srouceFile, destFile, (err: Error | undefined) => resolve(err));
|
||
|
});
|
||
|
assert(!err);
|
||
|
assert(existsSync(destFile));
|
||
|
Deno.removeSync(srouceFile);
|
||
|
Deno.removeSync(destFile);
|
||
|
},
|
||
|
});
|
||
|
|
||
|
test({
|
||
|
name: "[std/node/fs] copy file sync",
|
||
|
fn: () => {
|
||
|
const srouceFile = Deno.makeTempFileSync();
|
||
|
copyFileSync(srouceFile, destFile);
|
||
|
assert(existsSync(destFile));
|
||
|
Deno.removeSync(srouceFile);
|
||
|
Deno.removeSync(destFile);
|
||
|
},
|
||
|
});
|