How to use the link-lib.defaultNS.example function in link-lib

To help you get started, we’ve selected a few link-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fletcher91 / link-redux / src / components / __tests__ / LinkedResourceContainer.spec.ts View on Github external
/* eslint no-magic-numbers: 0 */
import { mount } from "enzyme";
import { defaultNS, LinkedRenderStore, RENDER_CLASS_NAME } from "link-lib";
import { BlankNode, Literal, Statement } from "rdflib";
import { createElement } from "react";

import * as ctx from "../../../test/fixtures";
import { LinkedResourceContainer } from "../LinkedResourceContainer";

const id = "resources/5";
const iri = defaultNS.example(id);

const createTestElement = (className = "testComponent") => () => createElement(
    "span",
    { className },
);
const loadLinkedObject = () => undefined;

describe("LinkedResourceContainer component", () => {
    it("renders null when type is not present", () => {
        const opts = ctx.empty(iri);
        const comp = createElement(LinkedResourceContainer, {
            className: "testmarker",
            loadLinkedObject,
            subject: iri,
        });
github fletcher91 / link-redux / src / hocs / __tests__ / link.spec.ts View on Github external
/* eslint no-magic-numbers: 0 */
import { mount } from "enzyme";
import { defaultNS, LinkedRenderStore } from "link-lib";
import { Literal, NamedNode, Statement } from "rdflib";
import * as React from "react";
import { Component } from "react";

import * as ctx from "../../../test/fixtures";
import { dataPropsToPropMap, link } from "../link";

const id = "resources/5";
const iri = defaultNS.example(id);

class TestComponent extends Component {
    public render() {
        return React.createElement("span", { className: "testComponent" });
    }
}

describe("link", () => {
    describe("dataPropsToPropMap", () => {
        describe("with array mapping", () => {
            it("throws with an empty map", () => {
                expect(() => {
                    dataPropsToPropMap([], {});
                }).toThrowError(TypeError);
            });
        });
github fletcher91 / link-redux / src / redux / __tests__ / linkedVersion.spec.ts View on Github external
it("does not raise with a subject", () => {
        const opts = ctx.empty();
        const comp = linkedVersion(() => null);
        let caught = false;
        try {
            mapStateToProps(new Map(), { subject: defaultNS.example("1") });
        } catch (e) {
            caught = true;
        }

        expect(caught).toEqual(false);
    });
github fletcher91 / link-redux / src / hooks / __tests__ / useDataInvalidation.spec.ts View on Github external
it("merges dataSubjects with the subject", () => {
            expect(normalizeDataSubjects({
                dataSubjects: [defaultNS.example("Roy")],
                subject: defaultNS.example("Tim"),
            })).toEqual([
                defaultNS.example("Tim"),
                defaultNS.example("Roy"),
            ]);
        });
github fletcher91 / link-redux / src / hooks / __tests__ / useDataInvalidation.spec.ts View on Github external
it("makes an array from the subject", () => {
            expect(normalizeDataSubjects({ subject: defaultNS.example("Tim") }))
                .toEqual([defaultNS.example("Tim")]);
        });
github fletcher91 / link-redux / src / components / __tests__ / PropertyBase.spec.ts View on Github external
it("returns true when subject is changed", () => {
            const opts = ctx.fullCW(subject);

            const comp = getComp();
            const elem = mount(opts.wrapComponent(comp)).find(CustomClass).instance();

            const nextProps = { label, subject: NS.example("different") };
            expect(elem.shouldComponentUpdate(nextProps)).toEqual(true);
        });
    });
github fletcher91 / link-redux / src / components / __tests__ / PropertyBase.spec.ts View on Github external
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")),
            ]);
        });
    });
github fletcher91 / link-redux / src / components / __tests__ / TopologyProvider.spec.ts View on Github external
it("sets the topology", () => {
        const opts = ctx.multipleCWArr([{ id: iri }, { id: defaultNS.example("resources/10") }]);
        opts.lrs.registerAll(LinkedRenderStore.registerRenderer(
            createTestElement("normalRendered"),
            defaultNS.schema("CreativeWork"),
        ));
        opts.lrs.registerAll(LinkedRenderStore.registerRenderer(
            createTestElement("collectionRendered"),
            defaultNS.schema("CreativeWork"),
            RENDER_CLASS_NAME,
            defaultNS.example("collection"),
        ));

        class CollectionProvider extends TopologyProvider {
            constructor(props) {
                super(props);
                this.topology = defaultNS.example("collection");
            }
github fletcher91 / link-redux / test / fixtures.ts View on Github external
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")),
    ];
};