mirror of
https://github.com/morluto/rea
synced 2026-10-27 06:33:32 -04:00
fix(semantics): preserve empty string property keys (#764)
Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This commit is contained in:
committed by
GitHub
parent
dd3640548f
commit
630bdafcac
@@ -310,3 +310,42 @@ it.each([
|
||||
).toEqual([]);
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
"const routes = {'': 'HOME'}; const root = routes[''];",
|
||||
"const routes = {'': 'HOME'}; const {'': root} = routes;",
|
||||
])(
|
||||
"preserves empty property identities with valid display labels: %s",
|
||||
(source) => {
|
||||
const graph = graphFor(source);
|
||||
expect(graph.nodes).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
kind: "property-slot",
|
||||
label: '""',
|
||||
properties: expect.objectContaining({ name: "" }),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
const root = graph.nodes.find(
|
||||
({ kind, label }) => kind === "binding" && label === "root",
|
||||
);
|
||||
const literal = graph.nodes.find(
|
||||
({ kind, identity, properties }) =>
|
||||
kind === "literal" &&
|
||||
properties.value === "HOME" &&
|
||||
identity.role_key.includes(":binding:root:"),
|
||||
);
|
||||
expect(literal).toBeDefined();
|
||||
expect(graph.relations).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
source_node_id: literal?.node_id,
|
||||
target_node_id: root?.node_id,
|
||||
relation: "defines",
|
||||
resolution: "resolved",
|
||||
}),
|
||||
]),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user