Files
reverse-engineering-anything/tests/support/expectInvalidInspectionInputs.ts
T
Vincent Koc 4bcd0af58c test(diagnostics): share invalid inspection input assertions (#14501)
* test(diagnostics): share invalid inspection input assertions

* test(diagnostics): keep the PE import fixture independently mergeable
2026-11-25 08:34:03 -05:00

27 lines
982 B
TypeScript

import { expect, vi } from "vitest";
import type { AnalysisError } from "../../src/domain/analysisErrorBase.js";
import { AnalysisInputError } from "../../src/domain/analysisErrorCore.js";
import { ok, type Result } from "../../src/domain/result.js";
export async function expectInvalidInspectionInputs<
Report extends { artifact: { path: string } },
>(
report: Report,
relativePath: string,
createService: (inspect: () => Promise<Result<Report, never>>) => {
inspect(input: unknown): Promise<Result<unknown, AnalysisError>>;
},
): Promise<void> {
const inspect = vi.fn(() => Promise.resolve(ok(report)));
const service = createService(inspect);
for (const input of [
{ path: relativePath },
{ path: report.artifact.path, extra: true },
]) {
const result = await service.inspect(input);
expect(result.ok).toBe(false);
if (!result.ok) expect(result.error).toBeInstanceOf(AnalysisInputError);
}
expect(inspect).not.toHaveBeenCalled();
}