From 209f0666ec3cddbe2c378968c0a8233dbc460191 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 13 Aug 2020 11:24:58 +0100 Subject: [PATCH] fix: screens not creating properly on electron --- .../userInterface/pagesParsing/createProps.js | 2 +- packages/builder/tests/createProps.spec.js | 37 +++++++------------ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/packages/builder/src/components/userInterface/pagesParsing/createProps.js b/packages/builder/src/components/userInterface/pagesParsing/createProps.js index 7e213f82df..44d23c5c3e 100644 --- a/packages/builder/src/components/userInterface/pagesParsing/createProps.js +++ b/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 = [] } diff --git a/packages/builder/tests/createProps.spec.js b/packages/builder/tests/createProps.spec.js index 3759598c1a..e4e6b385a7 100644 --- a/packages/builder/tests/createProps.spec.js +++ b/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 ", () => { - const comp = getcomponent() - - const { props, errors } = createProps(comp) - - expect(errors).toEqual([]) - expect(props._children).not.toBeDefined() - }) - - it("should not create _children array when children=false ", () => { + 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() + + const comp2 = getcomponent() + comp2.children = true + + const createRes2 = createProps(comp) + + expect(createRes2.errors).toEqual([]) + expect(createRes2.props._children).toBeDefined() }) it("should create an object with multiple prop names", () => {