Browse Source

fix: screens not creating properly on electron

pull/534/head
Michael Shanks 6 years ago
parent
commit
6bccb6f57b
  1. 2
      packages/builder/src/components/userInterface/pagesParsing/createProps.js
  2. 33
      packages/builder/tests/createProps.spec.js

2
packages/builder/src/components/userInterface/pagesParsing/createProps.js

@ -48,7 +48,7 @@ export const createProps = (componentDefinition, derivedFromProps) => {
assign(props, derivedFromProps)
}
if (componentDefinition.children && isUndefined(props._children)) {
if (isUndefined(props._children)) {
props._children = []
}

33
packages/builder/tests/createProps.spec.js

@ -18,7 +18,7 @@ describe("createDefaultProps", () => {
expect(props.fieldName).toBeDefined()
expect(props.fieldName).toBe("something")
stripStandardProps(props)
expect(keys(props).length).toBe(2)
expect(keys(props).length).toBe(3)
})
it("should set component _component", () => {
@ -72,16 +72,6 @@ describe("createDefaultProps", () => {
expect(props._children).toEqual([])
})
it("should create a object without _children array, when children===false ", () => {
const comp = getcomponent()
comp.children = false
const { props, errors } = createProps(comp)
expect(errors).toEqual([])
expect(props._children).not.toBeDefined()
})
it("should create a object with single empty array, when prop definition is 'event' ", () => {
const comp = getcomponent()
comp.props.onClick = "event"
@ -104,23 +94,22 @@ describe("createDefaultProps", () => {
expect(props._children).toEqual([])
})
it("should not create a _children array when children not defined ", () => {
it("should always create _children ", () => {
const comp = getcomponent()
comp.children = false
const { props, errors } = createProps(comp)
const createRes1 = createProps(comp)
expect(errors).toEqual([])
expect(props._children).not.toBeDefined()
})
expect(createRes1.errors).toEqual([])
expect(createRes1.props._children).toBeDefined()
it("should not create _children array when children=false ", () => {
const comp = getcomponent()
comp.children = false
const comp2 = getcomponent()
comp2.children = true
const { props, errors } = createProps(comp)
const createRes2 = createProps(comp)
expect(errors).toEqual([])
expect(props._children).not.toBeDefined()
expect(createRes2.errors).toEqual([])
expect(createRes2.props._children).toBeDefined()
})
it("should create an object with multiple prop names", () => {

Loading…
Cancel
Save