|
1 | | -import { requirementTests } from "./commentTestHandlers"; |
| 1 | +import { |
| 2 | + requirementTests, |
| 3 | + type RequirementHandler, |
| 4 | +} from "./commentTestHandlers"; |
2 | 5 | import type { TestFunction } from "./commentTestTypes"; |
3 | | -import { expect } from "bun:test"; |
4 | 6 |
|
5 | 7 | interface TestManagerOptions { |
6 | 8 | testFunctions: TestFunction[]; |
7 | 9 | } |
8 | 10 | export class TestManager { |
9 | 11 | private readonly testFunctions: TestFunction[]; |
10 | | - private readonly testMap: Map<string, TestFunction>; |
11 | 12 | public readonly nameFormat = "%s"; |
12 | | - // @ts-expect-error: Implicit any type |
13 | | - public readonly invoke = (_name, testFunc, reqHandler) => { |
14 | | - const failure: null | string = reqHandler(testFunc); |
15 | | - if (failure) { |
16 | | - expect().fail(failure); |
17 | | - } else { |
18 | | - expect().pass(); |
19 | | - } |
20 | | - }; |
21 | 13 |
|
22 | 14 | constructor(options: TestManagerOptions) { |
23 | 15 | this.testFunctions = options.testFunctions; |
24 | | - this.testMap = new Map( |
25 | | - this.testFunctions.map((testFunc) => [testFunc.name, testFunc]), |
26 | | - ); |
| 16 | + } |
| 17 | + |
| 18 | + public invokeWith(failureCallback: (failure: string) => void) { |
| 19 | + return ( |
| 20 | + _name: string, |
| 21 | + testFunc: TestFunction, |
| 22 | + reqHandler: RequirementHandler, |
| 23 | + ) => { |
| 24 | + const failure: null | string = reqHandler(testFunc); |
| 25 | + if (failure) { |
| 26 | + failureCallback(failure); |
| 27 | + } |
| 28 | + }; |
27 | 29 | } |
28 | 30 |
|
29 | 31 | public get allTests() { |
|
0 commit comments