1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 00:29:09 -05:00
denoland-deno/std/fs/write_file_str_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

37 lines
1.1 KiB
TypeScript

import { assertEquals } from "../testing/asserts.ts";
import * as path from "../path/mod.ts";
import { writeFileStr, writeFileStrSync } from "./write_file_str.ts";
const testdataDir = path.resolve("fs", "testdata");
Deno.test("testReadFileSync", function (): void {
const jsonFile = path.join(testdataDir, "write_file_1.json");
const content = "write_file_str_test";
writeFileStrSync(jsonFile, content);
// make sure file have been create.
Deno.statSync(jsonFile);
const result = new TextDecoder().decode(Deno.readFileSync(jsonFile));
// remove test file
Deno.removeSync(jsonFile);
assertEquals(content, result);
});
Deno.test("testReadFile", async function (): Promise<void> {
const jsonFile = path.join(testdataDir, "write_file_2.json");
const content = "write_file_str_test";
await writeFileStr(jsonFile, content);
// make sure file have been create.
await Deno.stat(jsonFile);
const result = new TextDecoder().decode(await Deno.readFile(jsonFile));
// remove test file
await Deno.remove(jsonFile);
assertEquals(content, result);
});