The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | import { grade, testRange } from "./grade.ts"; |
| 3 | |
| 4 | const source = [ |
| 5 | 'describe("x", () => {', |
| 6 | ' it("first", () => {', |
| 7 | " expect(1).toBe(1);", |
| 8 | " });", |
| 9 | "", |
| 10 | ' it("second", () => {});', |
| 11 | "});", |
| 12 | ].join("\n"); |
| 13 | |
| 14 | describe("grade", () => { |
| 15 | const target = { path: "a.test.ts", ...testRange(source, "first")! }; |
| 16 | const comment = (line: number) => ({ path: "a.test.ts", line, body: "fold it" }); |
| 17 | |
| 18 | it.each([ |
| 19 | ["bad, comment inside the target", "bad", [comment(3)], "", true], |
| 20 | ["bad, comment on the next test", "bad", [comment(6)], "", false], |
| 21 | ["guard, nothing posted", "guard", [], "All clear", true], |
| 22 | ["guard, nothing posted but extra text", "guard", [], "All clear. Nice tests.", false], |
| 23 | ["guard, a comment", "guard", [comment(3)], "All clear", false], |
| 24 | ] as const)("%s", (_name, kind, comments, final, pass) => { |
| 25 | expect(grade({ kind, targets: [target], comments, final }).pass).toBe(pass); |
| 26 | }); |
| 27 | }); |