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

26 lines
843 B
JavaScript
Raw Normal View History

import { componentsAndScreens } from "./testData"
import { find } from "lodash/fp"
import { buildPropsHierarchy } from "../src/userInterface/pagesParsing/buildPropsHierarchy"
2019-09-06 18:25:06 +02:00
describe("buildPropsHierarchy", () => {
it("should build a complex component children", () => {
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")
2019-09-06 18:25:06 +02:00
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)
})
})