Add a true assertion and assertion test file.
This commit is contained in:
parent
a0d46f7018
commit
85b835eba1
|
@ -27,6 +27,16 @@ export class TestContext {
|
||||||
title,
|
title,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Assert that the value is true. */
|
||||||
|
true(actual: boolean, title?: string): void {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
|
||||||
|
if (actual === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new AssertionError("Failed true assertion", actual, true, title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Special options for test cases. */
|
/** Special options for test cases. */
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import {setup} from "../source/index.js";
|
||||||
|
|
||||||
|
await setup("Assertions", async (group) => {
|
||||||
|
group.test("equals", async (test) => {
|
||||||
|
test.equals(true, true, "boolean");
|
||||||
|
test.equals(Math.PI, Math.PI, "number");
|
||||||
|
test.equals("A string!", "A string!", "string");
|
||||||
|
});
|
||||||
|
|
||||||
|
group.test("true", async (test) => {
|
||||||
|
test.true(1 > 0, "logic");
|
||||||
|
test.true(new Date() instanceof Date, "instanceof");
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,5 +1,7 @@
|
||||||
import {setup} from "../source/index.js";
|
import {setup} from "../source/index.js";
|
||||||
|
|
||||||
|
await import("./assertions.js");
|
||||||
|
|
||||||
async function add(a: number, b: number): Promise<number> {
|
async function add(a: number, b: number): Promise<number> {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
Loading…
Reference in New Issue