Will not create a set when not described by the context

main
Jackson Morgan 7 months ago
parent e1a277043b
commit 94dae83c4a
  1. 4
      packages/jsonld-dataset-proxy/src/subjectProxy/getValueForKey.ts
  2. 6
      packages/jsonld-dataset-proxy/test/jsonldDatasetProxy.test.ts

@ -52,13 +52,11 @@ export function getValueForKey(
} }
if (objectDataset.size === 0) { if (objectDataset.size === 0) {
return undefined; return undefined;
} else if (objectDataset.size === 1) { } else {
const thing = nodeToJsonldRepresentation( const thing = nodeToJsonldRepresentation(
objectDataset.toArray()[0].object, objectDataset.toArray()[0].object,
proxyContext, proxyContext,
); );
return thing; return thing;
} else {
return proxyContext.createSetProxy([subject, predicate, null, null]);
} }
} }

@ -544,9 +544,13 @@ const testJsonldDatasetProxy = (patientContext: LdoJsonldContext) => () => {
it("Creates a blank node if the id is blank during set", async () => { it("Creates a blank node if the id is blank during set", async () => {
const [dataset, observation] = await getEmptyObservationDataset(); const [dataset, observation] = await getEmptyObservationDataset();
observation.type = { "@id": "Observation" }; observation.type = { "@id": "Observation" };
console.log("1");
observation.subject = { type: { "@id": "Patient" }, name: set("Joe") }; observation.subject = { type: { "@id": "Patient" }, name: set("Joe") };
console.log("2");
expect(observation.subject?.["@id"]).toBeUndefined(); expect(observation.subject?.["@id"]).toBeUndefined();
expect(observation.subject.name).toEqual(["Joe"]); console.log("here");
expect(observation.subject.name).toContain("Joe");
console.log("there");
expect( expect(
dataset dataset
.match( .match(

Loading…
Cancel
Save