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