Open History to see the last commit
1// A test of an eval script, which works on plain file paths.
2// @effect-diagnostics nodeBuiltinImport:off
3import * as NodePath from "node:path";
4
5import { expect, it } from "vite-plus/test";
6
7import { cases } from "./cases.ts";
8import { grade } from "./grade.ts";
9
10const fixture = (name: string) => NodePath.join(import.meta.dirname, "fixtures", `${name}.ts`);
11const entry = (id: string) => cases.find((candidate) => candidate.id === id)!;
12
13it.each(cases.map((candidate) => candidate.id))("a correct answer to %s passes", async (id) => {
14 expect(await grade(fixture(id), entry(id))).toEqual([]);
15});
16
17it("a body that reads the clock outside a step fails the replay case", async () => {
18 expect(
19 await grade(fixture("replay-reads-outside-a-step"), entry("replay-keeps-what-it-read")),
20 ).toEqual([
21 "restart while waiting: The time it returned was read again after the restart, not kept from the start.",
22 ]);
23});
24
25it("a body that keeps the time in a module variable fails the replay case", async () => {
26 expect(
27 await grade(fixture("replay-keeps-in-a-module"), entry("replay-keeps-what-it-read")),
28 ).toEqual([
29 "restart while waiting: The time it returned was read again after the restart, not kept from the start.",
30 ]);
31});
32
33it("an answer to another task fails with the reason", async () => {
34 expect(
35 await grade(fixture("webhook-filter-and-dedupe"), entry("replay-keeps-what-it-read")),
36 ).toEqual(["restart while waiting: No workflow named stamp is defined."]);
37});