2020-01-18 00:06:42 +01:00
|
|
|
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", () => {
|
|
|
|
|
|
|
|
|
2020-01-18 00:06:42 +01:00
|
|
|
it("should build a complex component children", () => {
|
2019-09-06 18:25:06 +02:00
|
|
|
|
2020-01-18 00:06:42 +01:00
|
|
|
const {components, screens} = componentsAndScreens();
|
2019-09-06 18:25:06 +02:00
|
|
|
|
|
|
|
const allprops = buildPropsHierarchy(
|
2020-01-18 00:06:42 +01:00
|
|
|
components, screens, "ButtonGroup");
|
2019-09-06 18:25:06 +02:00
|
|
|
|
|
|
|
expect(allprops._component).toEqual("budibase-components/div");
|
|
|
|
|
|
|
|
const primaryButtonProps = () => ({
|
2020-01-18 00:06:42 +01:00
|
|
|
_component: "budibase-components/Button"
|
2019-09-06 18:25:06 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
const button1 = primaryButtonProps();
|
|
|
|
button1.contentText = "Button 1";
|
2020-01-18 00:06:42 +01:00
|
|
|
expect(allprops._children[0]).toEqual(button1);
|
2019-09-06 18:25:06 +02:00
|
|
|
|
|
|
|
const button2 = primaryButtonProps();
|
|
|
|
button2.contentText = "Button 2";
|
2020-01-18 00:06:42 +01:00
|
|
|
expect(allprops._children[1]).toEqual(button2)
|
2019-09-06 18:25:06 +02:00
|
|
|
});
|
|
|
|
});
|