mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
Move testdata/read_file_sync.ts to tests.ts
We don't need to start a new process for every test.
This commit is contained in:
parent
08d3850fa8
commit
33f488354c
3 changed files with 20 additions and 18 deletions
14
testdata/read_file_sync.ts
vendored
14
testdata/read_file_sync.ts
vendored
|
@ -1,14 +0,0 @@
|
||||||
import { readFileSync } from "deno";
|
|
||||||
|
|
||||||
let data = readFileSync("package.json");
|
|
||||||
if (!data.byteLength) {
|
|
||||||
throw Error(`Expected positive value for data.byteLength ${data.byteLength}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const decoder = new TextDecoder("utf-8");
|
|
||||||
const json = decoder.decode(data);
|
|
||||||
const pkg = JSON.parse(json);
|
|
||||||
if (pkg.name !== "deno") {
|
|
||||||
throw Error(`Expected "deno" but got "${pkg.name}"`)
|
|
||||||
}
|
|
||||||
console.log("package.name ", pkg.name);
|
|
1
testdata/read_file_sync.ts.out
vendored
1
testdata/read_file_sync.ts.out
vendored
|
@ -1 +0,0 @@
|
||||||
package.name deno
|
|
23
tests.ts
23
tests.ts
|
@ -1,5 +1,22 @@
|
||||||
import { test, assert } from "./deno_testing/testing.ts";
|
// This test is executed as part of integration_test.go
|
||||||
|
// But it can also be run manually:
|
||||||
|
// ./deno tests.ts
|
||||||
|
import { test, assert, assertEqual } from "./deno_testing/testing.ts";
|
||||||
|
import { readFileSync } from "deno";
|
||||||
|
|
||||||
test(async function test_matchTesters() {
|
test(async function tests_test() {
|
||||||
assert(false, "assert failed on purpose.");
|
assert(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(async function tests_readFileSync() {
|
||||||
|
let data = readFileSync("package.json");
|
||||||
|
if (!data.byteLength) {
|
||||||
|
throw Error(
|
||||||
|
`Expected positive value for data.byteLength ${data.byteLength}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const decoder = new TextDecoder("utf-8");
|
||||||
|
const json = decoder.decode(data);
|
||||||
|
const pkg = JSON.parse(json);
|
||||||
|
assertEqual(pkg.name, "deno");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue