test/tests/index.ts

67 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-12-22 13:00:03 +00:00
import {setup} from "../source/index.js";
await import("./assertions.js");
await import("./example.js");
2022-12-22 13:00:03 +00:00
async function add(a: number, b: number): Promise<number> {
await new Promise<void>((resolve) => {
setTimeout(() => {
resolve();
}, Math.random() * 1000);
});
return a + b;
}
async function subtract(a: number, b: number): Promise<number> {
await new Promise<void>((resolve) => {
setTimeout(() => {
resolve();
}, Math.random() * 1000);
});
return a - b;
}
2024-01-27 12:04:13 +00:00
await setup("add", async (group) => {
2022-12-22 13:00:03 +00:00
group.test("add(1, 1) = 2", async (test) => {
test.equals(await add(1, 1), 2);
});
group.skip("add(1, 1) = 3", async (test) => {
test.equals(await add(1, 1), 3);
});
group.test("add(1, 1) = 4", async (test) => {
test.equals(await add(1, 1), 4);
});
});
2024-01-27 12:04:13 +00:00
await setup(
2022-12-27 14:25:04 +00:00
"subtract",
async (group) => {
group.beforeAll(async () => {
console.log("subtract beforeAll hook");
});
group.afterAll(async () => {
console.log("subtract afterAll hook");
});
group.test("subtract(1, 1) = 0", async (test) => {
test.equals(await subtract(1, 1), 0);
});
group.skip("subtract(1, 1) = 1", async (test) => {
test.equals(await subtract(1, 1), 1);
});
group.test("subtract(1, 1) = 2", async (test) => {
test.equals(await subtract(1, 1), 2, "extra title");
});
},
{
parallel: false,
},
);