mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 13:24:20 +00:00
test(diagnostics): share invalid inspection input assertions (#14501)
* test(diagnostics): share invalid inspection input assertions * test(diagnostics): keep the PE import fixture independently mergeable
This commit is contained in:
1 parent
d0c51d1fa0
commit
4bcd0af58c
9 files changed
+87
-183
No files matched your search
@@ -0,0 +1,26 @@
|
||||
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();
|
||||
}
|
||||
Reference in new issue
Block a user