Compare commits
2 Commits
a0d46f7018
...
a0ee7b94c2
Author | SHA1 | Date |
---|---|---|
Bauke | a0ee7b94c2 | |
Bauke | 85b835eba1 |
|
@ -27,6 +27,26 @@ export class TestContext {
|
|||
title,
|
||||
);
|
||||
}
|
||||
|
||||
/** Assert that the value is false. */
|
||||
false(actual: boolean, title?: string): void {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
|
||||
if (actual === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AssertionError("Failed false assertion", actual, false, 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. */
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
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("false", async (test) => {
|
||||
test.false(1 < 0, "logic");
|
||||
test.false(new Date() instanceof String, "instanceof");
|
||||
});
|
||||
|
||||
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";
|
||||
|
||||
await import("./assertions.js");
|
||||
|
||||
async function add(a: number, b: number): Promise<number> {
|
||||
await new Promise<void>((resolve) => {
|
||||
setTimeout(() => {
|
||||
|
|
Loading…
Reference in New Issue