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

38 lines
986 B
JavaScript
Raw Normal View History

2019-07-28 09:03:11 +02:00
import {
searchAllComponents,
getExactComponent,
getAncestorProps,
} from "../src/components/userInterface/pagesParsing/searchComponents"
import { componentsAndScreens } from "./testData"
2019-07-28 09:03:11 +02:00
describe("getExactComponent", () => {
it("should get component by name", () => {
const { components } = componentsAndScreens()
const result = getExactComponent(
components,
"TextBox"
)
expect(result).toBeDefined()
expect(result._instanceName).toBe("TextBox")
})
test("Should not find as isScreen is not specified", () => {
const { screens } = componentsAndScreens()
const result = getExactComponent(screens, "SmallTextbox")
expect(result).not.toBeDefined()
})
2019-07-28 09:03:11 +02:00
test("Should find as isScreen is specified", () => {
const { screens } = componentsAndScreens()
const result = getExactComponent(screens, "SmallTextbox", true)
expect(result).toBeDefined()
expect(result.props._instanceName).toBe("SmallTextbox")
})
})