mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 20:53:00 +00:00
test(javascript): consolidate graph and version comparison coverage
This commit is contained in:
1 parent
1881bbb55b
commit
025df6ec30
9 files changed
+747
-889
No files matched your search
@@ -109,37 +109,6 @@ const compare = (
|
||||
rightNativeEvidence: [],
|
||||
});
|
||||
|
||||
it("keeps unmatched unavailable scopes unknown in either direction", () => {
|
||||
const leftRoot = node("d".repeat(64), "main.js");
|
||||
const rightRoot = node("d".repeat(64), "main.js");
|
||||
const leftScope = unavailableScope(LEFT_SHA);
|
||||
const rightScope = unavailableScope(RIGHT_SHA);
|
||||
const forward = compare([leftRoot], [rightRoot, rightScope]);
|
||||
const reverse = compare([leftRoot, leftScope], [rightRoot]);
|
||||
|
||||
expect(
|
||||
forward.items.find(
|
||||
({ right_node_id }) => right_node_id === rightScope.node_id,
|
||||
),
|
||||
).toMatchObject({
|
||||
status: "unknown",
|
||||
dimensions: ["availability"],
|
||||
limitations: [LIMITATION],
|
||||
evidence_links: [evidenceId("1"), evidenceId("2")],
|
||||
});
|
||||
expect(
|
||||
reverse.items.find(
|
||||
({ left_node_id }) => left_node_id === leftScope.node_id,
|
||||
),
|
||||
).toMatchObject({
|
||||
status: "unknown",
|
||||
dimensions: ["availability"],
|
||||
limitations: [LIMITATION],
|
||||
});
|
||||
expect(forward.summary).toMatchObject({ added: 0, removed: 0, unknown: 1 });
|
||||
expect(reverse.summary).toMatchObject({ added: 0, removed: 0, unknown: 1 });
|
||||
});
|
||||
|
||||
it("keeps matched unavailable scopes unknown with their source limitation", () => {
|
||||
const leftRoot = node("d".repeat(64), "main.js");
|
||||
const rightRoot = node("d".repeat(64), "main.js");
|
||||
@@ -162,48 +131,52 @@ it("retains unknown scope facts and reports genuine entity changes", () => {
|
||||
const leftRoot = node("d".repeat(64), "main.js");
|
||||
const rightRoot = node("d".repeat(64), "main.js");
|
||||
const unknown = unavailableScope(RIGHT_SHA, "unknown");
|
||||
const added = node("e".repeat(64), "new.js");
|
||||
const unavailable = unavailableScope(LEFT_SHA);
|
||||
const removed = node("f".repeat(64), "removed.js");
|
||||
const mixedEvidenceAddition = observedAssetWithUnavailableFact();
|
||||
const unknownResult = compare([leftRoot], [rightRoot, unknown]);
|
||||
const addedResult = compare([leftRoot], [rightRoot, added]);
|
||||
const removedResult = compare([leftRoot, removed], [rightRoot]);
|
||||
const mixedResult = compare([leftRoot], [rightRoot, mixedEvidenceAddition]);
|
||||
const added = observedAssetWithUnavailableFact();
|
||||
const result = compare(
|
||||
[leftRoot, removed, unavailable],
|
||||
[rightRoot, added, unknown],
|
||||
);
|
||||
|
||||
expect(
|
||||
unknownResult.items.find(
|
||||
({ right_node_id }) => right_node_id === unknown.node_id,
|
||||
),
|
||||
).toMatchObject({ status: "unknown", limitations: [LIMITATION] });
|
||||
expect(unknownResult.summary).toMatchObject({ added: 0, unknown: 1 });
|
||||
expect(
|
||||
addedResult.items.find(
|
||||
({ right_node_id }) => right_node_id === added.node_id,
|
||||
),
|
||||
).toMatchObject({ status: "added", dimensions: ["availability"] });
|
||||
expect(addedResult.summary.added).toBe(1);
|
||||
expect(
|
||||
mixedResult.items.find(
|
||||
({ right_node_id }) => right_node_id === mixedEvidenceAddition.node_id,
|
||||
),
|
||||
).toMatchObject({ status: "added", limitations: [LIMITATION] });
|
||||
expect(mixedResult.summary.added).toBe(1);
|
||||
expect(
|
||||
removedResult.items.find(
|
||||
({ left_node_id }) => left_node_id === removed.node_id,
|
||||
),
|
||||
).toMatchObject({ status: "removed", dimensions: ["availability"] });
|
||||
expect(removedResult.summary.removed).toBe(1);
|
||||
expect(
|
||||
compare(
|
||||
[leftRoot, node("c".repeat(64), "same.js")],
|
||||
[rightRoot, node("c".repeat(64), "same.js")],
|
||||
).summary,
|
||||
).toMatchObject({
|
||||
unchanged: 2,
|
||||
added: 0,
|
||||
removed: 0,
|
||||
expect(result.summary).toEqual({
|
||||
unchanged: 1,
|
||||
added: 1,
|
||||
removed: 1,
|
||||
changed: 0,
|
||||
unknown: 2,
|
||||
});
|
||||
expect(result.items).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
left_node_id: unavailable.node_id,
|
||||
right_node_id: null,
|
||||
status: "unknown",
|
||||
dimensions: ["availability"],
|
||||
limitations: [LIMITATION],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
left_node_id: null,
|
||||
right_node_id: unknown.node_id,
|
||||
status: "unknown",
|
||||
dimensions: ["availability"],
|
||||
limitations: [LIMITATION],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
left_node_id: removed.node_id,
|
||||
right_node_id: null,
|
||||
status: "removed",
|
||||
dimensions: ["availability"],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
left_node_id: null,
|
||||
right_node_id: added.node_id,
|
||||
status: "added",
|
||||
dimensions: ["availability"],
|
||||
limitations: [LIMITATION],
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not treat unexamined source metadata as a file change", () => {
|
||||
|
||||
Reference in new issue
Block a user