mirror of
https://github.com/morluto/rea.git
synced 2026-11-29 09:56:23 +00:00
* test(diagnostics): share invalid inspection input assertions * test(diagnostics): keep the PE import fixture independently mergeable
27 lines
982 B
TypeScript
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();
|
|
}
|