|
|
@ -30,6 +30,12 @@ import { namedNode, quad, literal, defaultGraph } from "@rdfjs/data-model"; |
|
|
|
import type { Dataset, NamedNode } from "@rdfjs/types"; |
|
|
|
import type { Dataset, NamedNode } from "@rdfjs/types"; |
|
|
|
import type { ContextDefinition } from "jsonld"; |
|
|
|
import type { ContextDefinition } from "jsonld"; |
|
|
|
import type { LdoJsonldContext } from "../src/LdoJsonldContext"; |
|
|
|
import type { LdoJsonldContext } from "../src/LdoJsonldContext"; |
|
|
|
|
|
|
|
import { |
|
|
|
|
|
|
|
scopedContext, |
|
|
|
|
|
|
|
scopedData, |
|
|
|
|
|
|
|
type Avatar, |
|
|
|
|
|
|
|
type Bender, |
|
|
|
|
|
|
|
} from "./scopedExampleData"; |
|
|
|
|
|
|
|
|
|
|
|
const testJsonldDatasetProxy = (patientContext: LdoJsonldContext) => () => { |
|
|
|
const testJsonldDatasetProxy = (patientContext: LdoJsonldContext) => () => { |
|
|
|
async function getLoadedDataset(): Promise< |
|
|
|
async function getLoadedDataset(): Promise< |
|
|
@ -165,6 +171,19 @@ const testJsonldDatasetProxy = (patientContext: LdoJsonldContext) => () => { |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getScopedDataset(): Promise< |
|
|
|
|
|
|
|
[Dataset, Bender, Avatar, JsonldDatasetProxyBuilder] |
|
|
|
|
|
|
|
> { |
|
|
|
|
|
|
|
const dataset = await serializedToDataset(scopedData); |
|
|
|
|
|
|
|
const builder = await jsonldDatasetProxy(dataset, scopedContext); |
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
|
|
dataset, |
|
|
|
|
|
|
|
builder.fromSubject(namedNode("http://example.com/Katara")), |
|
|
|
|
|
|
|
builder.fromSubject(namedNode("http://example.com/Aang")), |
|
|
|
|
|
|
|
builder, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
describe("read", () => { |
|
|
|
describe("read", () => { |
|
|
|
it("retreives a primitive", async () => { |
|
|
|
it("retreives a primitive", async () => { |
|
|
|
const [, observation] = await getLoadedDataset(); |
|
|
|
const [, observation] = await getLoadedDataset(); |
|
|
@ -409,6 +428,13 @@ const testJsonldDatasetProxy = (patientContext: LdoJsonldContext) => () => { |
|
|
|
const [, observation] = await getLoadedDataset(); |
|
|
|
const [, observation] = await getLoadedDataset(); |
|
|
|
expect(observation["@context"]).toEqual(patientContext); |
|
|
|
expect(observation["@context"]).toEqual(patientContext); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it("reads an array for collections, but a var for non collections", async () => { |
|
|
|
|
|
|
|
const [, bender, avatar] = await getScopedDataset(); |
|
|
|
|
|
|
|
expect(avatar.element[0]["@id"]).toBe("http://example.com/Air"); |
|
|
|
|
|
|
|
expect(avatar.element[1]["@id"]).toBe("http://example.com/Water"); |
|
|
|
|
|
|
|
expect(bender.element["@id"]).toBe("http://example.com/Water"); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe("write", () => { |
|
|
|
describe("write", () => { |
|
|
|