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

31 lines
927 B
JavaScript
Raw Normal View History

import { componentsAndScreens } from "./testData";
2019-09-06 18:25:06 +02:00
import {
find
} from "lodash/fp";
import { buildPropsHierarchy } from "../src/userInterface/pagesParsing/buildPropsHierarchy";
describe("buildPropsHierarchy", () => {
it("should build a complex component children", () => {
2019-09-06 18:25:06 +02:00
const {components, screens} = componentsAndScreens();
2019-09-06 18:25:06 +02:00
const allprops = buildPropsHierarchy(
components, screens, "ButtonGroup");
2019-09-06 18:25:06 +02:00
expect(allprops._component).toEqual("budibase-components/div");
const primaryButtonProps = () => ({
_component: "budibase-components/Button"
2019-09-06 18:25:06 +02:00
});
const button1 = primaryButtonProps();
button1.contentText = "Button 1";
expect(allprops._children[0]).toEqual(button1);
2019-09-06 18:25:06 +02:00
const button2 = primaryButtonProps();
button2.contentText = "Button 2";
expect(allprops._children[1]).toEqual(button2)
2019-09-06 18:25:06 +02:00
});
});