How to use the link-lib.defaultNS.ex 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 / hocs / __tests__ / withLinkCtx.spec.tsx View on Github external
it("allows overriding subject", () => {
            const opts = ctx.fullCW();

            const Comp = withLinkCtx(TestComponent, { subject: true, lrs: true });
            const elem = ;
            const tree = mount(opts.wrapComponent(elem));
            const node = tree.find("TestComponent");

            // enzyme-matchers' `toHaveProps` does a slow recursive deep compare
            expect((node.props() as any).lrs).toEqual(opts.lrs);
            expect(node).toHaveProp("subject", defaultNS.ex("override"));
            expect(node).toHaveProp("topology", DEFAULT_TOPOLOGY);

            expect(node).toHaveProp("subjectCtx", opts.subject);
            expect(node).not.toHaveProp("topologyCtx");
        });
github fletcher91 / link-redux / src / hocs / __tests__ / link.spec.ts View on Github external
it("skips others' properties", () => {
                const dataProps = Object.create({ oLabel: defaultNS.ex("o") });
                dataProps.cLabel = defaultNS.ex("p");

                const [ propMap, requestedProperties ] = dataPropsToPropMap(dataProps, {});

                expect(propMap).toHaveProperty("cLabel");
                expect(propMap).not.toHaveProperty("oLabel");
                expect(requestedProperties).toEqual([defaultNS.ex("p").sI]);

                const { cLabel } = propMap;
                expect(cLabel).toHaveProperty("label", [defaultNS.ex("p")]);
                expect(cLabel).toHaveProperty("name", "cLabel");
            });
github fletcher91 / link-redux / src / hocs / __tests__ / link.spec.ts View on Github external
it("skips others' properties", () => {
                const dataProps = Object.create({ oLabel: defaultNS.ex("o") });
                dataProps.cLabel = defaultNS.ex("p");

                const [ propMap, requestedProperties ] = dataPropsToPropMap(dataProps, {});

                expect(propMap).toHaveProperty("cLabel");
                expect(propMap).not.toHaveProperty("oLabel");
                expect(requestedProperties).toEqual([defaultNS.ex("p").sI]);

                const { cLabel } = propMap;
                expect(cLabel).toHaveProperty("label", [defaultNS.ex("p")]);
                expect(cLabel).toHaveProperty("name", "cLabel");
            });
github fletcher91 / link-redux / src / __tests__ / register.spec.ts View on Github external
it("registers a class component", () => {
        class Comp extends Component {
            public static type = defaultNS.ex("TestClass");

            public render() { return null; }
        }
        const [ registration ] = register(Comp);

        expect(registration).toHaveProperty("component", Comp);
        expect(registration).toHaveProperty("property", RENDER_CLASS_NAME.sI);
        expect(registration).toHaveProperty("topology", DEFAULT_TOPOLOGY.sI);
        expect(registration).toHaveProperty("type", defaultNS.ex("TestClass").sI);
    });
github fletcher91 / link-redux / src / hocs / __tests__ / link.spec.ts View on Github external
it("processes a map with a NamedNode value", () => {
                const [ propMap, requestedProperties ] = dataPropsToPropMap({
                    cLabel: defaultNS.ex("p"),
                }, {});

                expect(propMap).toHaveProperty("cLabel");
                expect(requestedProperties).toEqual([defaultNS.ex("p").sI]);

                const { cLabel } = propMap;
                expect(cLabel).toHaveProperty("label", [defaultNS.ex("p")]);
                expect(cLabel).toHaveProperty("name", "cLabel");
            });
github fletcher91 / link-redux / src / components / __tests__ / Typable.spec.ts View on Github external
it("renders a registered no-view component", () => {
            const opts = ctx.empty();
            const errorComp = () => createElement("span", { className: "custom-no-view" });
            errorComp.type = defaultNS.ll("NoView");
            errorComp.topology = defaultNS.ex("t");
            opts.lrs.registerAll(register(errorComp));
            const element = renderNoView({
                subject: new BlankNode(),
                topology: defaultNS.ex("t"),
            }, opts.lrs);

            const tree = mount(element);

            expect(tree).toContainMatchingElement(".custom-no-view");
        });
    });
github fletcher91 / link-redux / src / __tests__ / register.spec.ts View on Github external
it("registers a class component", () => {
        class Comp extends Component {
            public static type = defaultNS.ex("TestClass");

            public render() { return null; }
        }
        const [ registration ] = register(Comp);

        expect(registration).toHaveProperty("component", Comp);
        expect(registration).toHaveProperty("property", RENDER_CLASS_NAME.sI);
        expect(registration).toHaveProperty("topology", DEFAULT_TOPOLOGY.sI);
        expect(registration).toHaveProperty("type", defaultNS.ex("TestClass").sI);
    });
github fletcher91 / link-redux / src / components / __tests__ / Property.spec.ts View on Github external
it("renders null when data is not present with forceRender", () => {
        const opts = ctx.fullCW();
        const elem = mount(opts.wrapComponent(React.createElement(
            Property,
            {
                forceRender: true,
                label: defaultNS.ex("nonexistent"),
                subject,
                ...opts.contextProps(),
            },
        )));
        expect(elem.find(Property).children()).toHaveLength(0);
    });
github fletcher91 / link-redux / src / hocs / __tests__ / link.spec.ts View on Github external
it("processes a map with an array value", () => {
                const [ propMap, requestedProperties ] = dataPropsToPropMap({
                    cLabel: [defaultNS.ex("p"), defaultNS.ex("q")],
                }, {});

                expect(propMap).toHaveProperty("cLabel");
                expect(requestedProperties).toEqual([defaultNS.ex("p").sI, defaultNS.ex("q").sI]);

                const { cLabel } = propMap;
                expect(cLabel).toHaveProperty("label", [defaultNS.ex("p"), defaultNS.ex("q")]);
                expect(cLabel).toHaveProperty("name", "cLabel");
            });
github fletcher91 / link-redux / src / hocs / __tests__ / link.spec.ts View on Github external
it("processes a map with an array value", () => {
                const [ propMap, requestedProperties ] = dataPropsToPropMap({
                    cLabel: [defaultNS.ex("p"), defaultNS.ex("q")],
                }, {});

                expect(propMap).toHaveProperty("cLabel");
                expect(requestedProperties).toEqual([defaultNS.ex("p").sI, defaultNS.ex("q").sI]);

                const { cLabel } = propMap;
                expect(cLabel).toHaveProperty("label", [defaultNS.ex("p"), defaultNS.ex("q")]);
                expect(cLabel).toHaveProperty("name", "cLabel");
            });