diff options
Diffstat (limited to 'tests.ts')
| -rw-r--r-- | tests.ts | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -2,7 +2,7 @@ // But it can also be run manually: // ./deno tests.ts import { test, assert, assertEqual } from "./deno_testing/testing.ts"; -import { readFileSync } from "deno"; +import { readFileSync, writeFileSync } from "deno"; test(async function tests_test() { assert(true); @@ -21,8 +21,20 @@ test(async function tests_readFileSync() { assertEqual(pkg.name, "deno"); }); +test(async function tests_writeFileSync() { + const enc = new TextEncoder(); + const data = enc.encode("Hello"); + // TODO need ability to get tmp dir. + const fn = "/tmp/test.txt"; + writeFileSync("/tmp/test.txt", data, 0o666); + const dataRead = readFileSync("/tmp/test.txt"); + const dec = new TextDecoder("utf-8"); + const actual = dec.decode(dataRead); + assertEqual("Hello", actual); +}); + test(async function tests_fetch() { - const response = await fetch('http://localhost:4545/package.json'); + const response = await fetch("http://localhost:4545/package.json"); const json = await response.json(); assertEqual(json.name, "deno"); }); |
