Skip to content

Commit

Permalink
wip: ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche committed Dec 11, 2024
1 parent 2295eb3 commit e6d1600
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions util/MockConductor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setupToolboxTester, TestContext } from '../src'
import { TestConductor } from '../src/conductor/TestConductor'
import { TestReporter } from '../src/conductor/TestReporter'
import { TestCompleteData, TestErrorData, TestReporter, TestResultData, TestScheduleData } from '../src/conductor/TestReporter'
import { TestHookType } from '../src/conductor/TestRun'
import { FsWatcher } from '../src/files/FsWatcher'
import { TestRunner } from '../src/runner'
Expand Down Expand Up @@ -89,10 +89,10 @@ export class MockConductor extends TestConductor {
const ctx = {}
new TestRunner(
{
schedule: async d => reporter.schedule(d),
result: async d => reporter.result(d),
error: async d => reporter.error(d),
complete: async d => reporter.complete(d),
schedule: async d => this.tryReport(reporter, 'schedule', d),
result: async d => this.tryReport(reporter, 'result', d),
error: async d => this.tryReport(reporter, 'error', d),
complete: async d => this.tryReport(reporter, 'complete', d),
},
undefined,
ctx,
Expand Down Expand Up @@ -144,6 +144,18 @@ export class MockConductor extends TestConductor {
ctx[hook](f as () => void)
})
}

protected tryReport<K extends 'schedule'|'result'|'error'|'complete'>(
reporter: TestReporter,
key: K,
data: Parameters<TestReporter[K]>[0],
) {
try {
reporter[key](data as (TestScheduleData & TestResultData & TestErrorData & TestCompleteData))
} catch {
return
}
}
}

export const results: MockResults = {
Expand Down

0 comments on commit e6d1600

Please sign in to comment.