mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 15:33:56 +08:00
test(javascript): share export shape summary expectations (#17370)
This commit is contained in:
@@ -18,6 +18,10 @@ import {
|
||||
createJavaScriptApplicationNode,
|
||||
} from "../../../src/domain/javascript/javascriptApplicationGraph.js";
|
||||
|
||||
const expectedSummary = (
|
||||
counts: Partial<ReturnType<typeof compare>["summary"]> = {},
|
||||
) => ({ added: 0, removed: 0, changed: 0, unknown: 0, ...counts });
|
||||
|
||||
const registerImplicitInvocationComparisonTests = (): void => {
|
||||
it("preserves accessor-effect uncertainty through analyzed Evidence and export comparison", async () => {
|
||||
const [left, right] = await analyzeSources({
|
||||
@@ -121,12 +125,7 @@ describe("JavaScript export return-shape comparison", () => {
|
||||
right: expect.objectContaining({ availability: "unknown" }),
|
||||
}),
|
||||
]);
|
||||
expect(result.summary).toEqual({
|
||||
added: 0,
|
||||
removed: 0,
|
||||
changed: 0,
|
||||
unknown: 1,
|
||||
});
|
||||
expect(result.summary).toEqual(expectedSummary({ unknown: 1 }));
|
||||
expect(result.coverage.status).toBe("partial");
|
||||
expect(inventoryProperties(result, "left", 0)).toEqual(
|
||||
expect.arrayContaining(["/kind", "/value", "/options", "/stable"]),
|
||||
@@ -140,18 +139,8 @@ describe("JavaScript export return-shape comparison", () => {
|
||||
});
|
||||
const forward = compare(left, right),
|
||||
reverse = compare(right, left);
|
||||
expect(forward.summary).toEqual({
|
||||
added: 2,
|
||||
removed: 0,
|
||||
changed: 0,
|
||||
unknown: 0,
|
||||
});
|
||||
expect(reverse.summary).toEqual({
|
||||
added: 0,
|
||||
removed: 2,
|
||||
changed: 0,
|
||||
unknown: 0,
|
||||
});
|
||||
expect(forward.summary).toEqual(expectedSummary({ added: 2 }));
|
||||
expect(reverse.summary).toEqual(expectedSummary({ removed: 2 }));
|
||||
expect(forward.changes).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -201,12 +190,7 @@ describe("JavaScript export source-owned parser comparison", () => {
|
||||
expect(() =>
|
||||
javaScriptExportShapeComparisonResultSchema.parse(first),
|
||||
).not.toThrow();
|
||||
expect(first.summary).toEqual({
|
||||
added: 1,
|
||||
removed: 0,
|
||||
changed: 0,
|
||||
unknown: 3,
|
||||
});
|
||||
expect(first.summary).toEqual(expectedSummary({ added: 1, unknown: 3 }));
|
||||
expect(first.changes.filter(({ status }) => status !== "unknown")).toEqual([
|
||||
expect.objectContaining({
|
||||
status: "added",
|
||||
@@ -488,12 +472,7 @@ describe("JavaScript export return-shape pairing limits", () => {
|
||||
discriminant: null,
|
||||
}),
|
||||
]);
|
||||
expect(result.summary).toEqual({
|
||||
added: 0,
|
||||
removed: 0,
|
||||
changed: 0,
|
||||
unknown: 2,
|
||||
});
|
||||
expect(result.summary).toEqual(expectedSummary({ unknown: 2 }));
|
||||
expect(result.coverage).toMatchObject({
|
||||
status: "partial",
|
||||
paired_variants: 0,
|
||||
@@ -805,12 +784,7 @@ describe("JavaScript export matching uncertain projections", () => {
|
||||
right: expect.objectContaining({ availability: "unknown" }),
|
||||
}),
|
||||
]);
|
||||
expect(result.summary).toEqual({
|
||||
added: 0,
|
||||
removed: 0,
|
||||
changed: 0,
|
||||
unknown: 1,
|
||||
});
|
||||
expect(result.summary).toEqual(expectedSummary({ unknown: 1 }));
|
||||
expect(result.coverage.status).toBe("partial");
|
||||
expect(
|
||||
result.property_inventories.every(
|
||||
@@ -898,12 +872,7 @@ describe("JavaScript export localized mutation uncertainty", () => {
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(result.summary).toEqual({
|
||||
added: 1,
|
||||
removed: 0,
|
||||
changed: 0,
|
||||
unknown: 1,
|
||||
});
|
||||
expect(result.summary).toEqual(expectedSummary({ added: 1, unknown: 1 }));
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -1042,12 +1011,7 @@ describe("JavaScript export return-shape property presence", () => {
|
||||
unpaired_left_variants: 1,
|
||||
unpaired_right_variants: 1,
|
||||
});
|
||||
expect(first.summary).toEqual({
|
||||
added: 0,
|
||||
removed: 0,
|
||||
changed: 0,
|
||||
unknown: 2,
|
||||
});
|
||||
expect(first.summary).toEqual(expectedSummary({ unknown: 2 }));
|
||||
expect(
|
||||
first.changes.every(({ discriminant }) => discriminant === null),
|
||||
).toBe(true);
|
||||
@@ -1369,12 +1333,7 @@ describe("JavaScript export return-shape projection", () => {
|
||||
expect([...inventory.properties].sort()).toEqual(paths);
|
||||
}
|
||||
expect(result.changes).toEqual([]);
|
||||
expect(result.summary).toEqual({
|
||||
added: 0,
|
||||
removed: 0,
|
||||
changed: 0,
|
||||
unknown: 0,
|
||||
});
|
||||
expect(result.summary).toEqual(expectedSummary());
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user