Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("uses the render store to resolve", () => {
const opts = ctx.fullCW(subject);
const comp = getComp();
const elem = mount(opts.wrapComponent(comp)).find(CustomClass).instance();
expect(elem.getLinkedObjectPropertyRaw()).toEqual([
new Statement(subject, label, new Literal("title"), NS.example("default")),
]);
});
it("renders blank nodes", () => {
const bn = new BlankNode();
const opts = ctx.chargeLRS(
[
new Statement(bn, defaultNS.rdf("type"), defaultNS.schema("Thing")),
new Statement(bn, defaultNS.schema("name"), new Literal("title")),
],
bn,
);
const comp = createTestElement();
opts.lrs.registerAll(LinkedRenderStore.registerRenderer(comp, defaultNS.schema("Thing")));
const elem = mount(
opts.wrapComponent(createElement(LinkedResourceContainer, {
loadLinkedObject,
subject: bn,
})),
);
expect(elem.find("span.testComponent")).toExist();
});
it("renders blank nodes", () => {
const bn = new BlankNode();
const opts = ctx.chargeLRS(
[
new Statement(bn, defaultNS.rdf("type"), defaultNS.schema("Thing")),
new Statement(bn, defaultNS.schema("name"), new Literal("title")),
],
bn,
);
const comp = createTestElement();
opts.lrs.registerAll(LinkedRenderStore.registerRenderer(comp, defaultNS.schema("Thing")));
const elem = mount(
opts.wrapComponent(createElement(LinkedResourceContainer, {
loadLinkedObject,
subject: bn,
})),
);
expect(elem.find("span.testComponent")).toExist();
});
it("allows the property to be passed", () => {
const opts = ctx.fullCW(subject);
const comp = getComp();
const elem = mount(opts.wrapComponent(comp)).find(CustomClass).instance();
expect(elem.getLinkedObjectPropertyRaw(NS.example("tags"))).toEqual([
new Statement(subject, NS.example("tags"), NS.example("tag/0"), NS.example("default")),
new Statement(subject, NS.example("tags"), NS.example("tag/1"), NS.example("default")),
new Statement(subject, NS.example("tags"), NS.example("tag/2"), NS.example("default")),
new Statement(subject, NS.example("tags"), NS.example("tag/3"), NS.example("default")),
]);
});
});
const sTitle = (id: NamedNode, title: string) => [
new Statement(id, NS.schema("name"), new Literal(title)),
];
const typeObject = id => [
new rdf.Statement(exNS(id), defaultNS.rdf('type'), schema('CreativeWork')),
];
const sFull = (id: NamedNode, attrs: Test) => {
return [
typeObject(id)[0],
new Statement(id, NS.schema("name"), new Literal(attrs.title || "title"), NS.example("default")),
new Statement(id, NS.schema("text"), new Literal(attrs.text || "text"), NS.example("default")),
new Statement(id, NS.schema("author"), new NamedNode(attrs.author || "http://example.org/people/0"), NS.example("default")),
new Statement(id, NS.schema("dateCreated"), Literal.fromDate(new Date("2019-01-01")), NS.example("default")),
new Statement(id, NS.ex("timesRead"), Literal.fromValue(5), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/0"), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/1"), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/2"), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/3"), NS.example("default")),
];
};
const sFull = (id: NamedNode, attrs: Test) => {
return [
typeObject(id)[0],
new Statement(id, NS.schema("name"), new Literal(attrs.title || "title"), NS.example("default")),
new Statement(id, NS.schema("text"), new Literal(attrs.text || "text"), NS.example("default")),
new Statement(id, NS.schema("author"), new NamedNode(attrs.author || "http://example.org/people/0"), NS.example("default")),
new Statement(id, NS.schema("dateCreated"), Literal.fromDate(new Date("2019-01-01")), NS.example("default")),
new Statement(id, NS.ex("timesRead"), Literal.fromValue(5), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/0"), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/1"), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/2"), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/3"), NS.example("default")),
];
};