budibase/packages/builder/tests/componentDependencies.spec.js

52 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-10-07 07:03:41 +02:00
import {
componentDependencies
} from "../src/userInterface/pagesParsing/findDependencies";
import { componentsAndScreens } from "./testData";
2019-10-07 07:03:41 +02:00
import { some, find } from "lodash/fp"
describe("component dependencies", () => {
const contains = (result, name) =>
some(c => c.name === name)(result);
const get = (all, name) =>
find(c => c.name === name)(all);
it("should include component that inheirts", () => {
const {components, screens} = componentsAndScreens();
2019-10-07 07:03:41 +02:00
const result = componentDependencies(
{}, screens, components,
get([...components, ...screens], "budibase-components/TextBox"));
2019-10-07 07:03:41 +02:00
expect(contains(result.dependantComponents, "common/SmallTextbox")).toBe(true);
});
it("should include component that nests", () => {
const {components, screens} = componentsAndScreens();
2019-10-07 07:03:41 +02:00
const result = componentDependencies(
{}, screens, components,
get([...components, ...screens], "budibase-components/Button"));
2019-10-07 07:03:41 +02:00
expect(contains(result.dependantComponents, "ButtonGroup")).toBe(true);
});
it("should include components n page apbody", () => {
const {components, screens} = componentsAndScreens();
2019-10-07 07:03:41 +02:00
const pages = {
main: {
appBody: "PrimaryButton"
}
};
const result = componentDependencies(
pages, screens, components,
get([...components, ...screens], "PrimaryButton"));
2019-10-07 07:03:41 +02:00
expect(result.dependantPages).toEqual(["main"]);
});
})