1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00
budibase/packages/client/tests/domControlFlow.spec.js
Michael Shanks f7bea46f01
Page Layout & Screen restructure (#87)
* refactoring server for screens & page layout restructure

* Disable API calls, UI placeholders.

* buildPropsHierarchy is gone & screen has url

* Recent changes.

* router

* router

* updated git-ignore to reinclude server/utilities/builder

* modified cli - budi new create new file structure

* Fix uuid import.

* prettier fixes

* prettier fixes

* prettier fixes

* page/screen restructure.. broken tests

* all tests passing at last

* screen routing tests

* Working screen editor and preview.

* Render page previews to the screen.

* Key input lists to ensure new array references when updating styles.

* Ensure the iframe html and body fills the container.

* Save screens via the API.

* Get all save APIs almost working.

* Write pages.json to disk.

* Use correct API endpoint for saving styles.

* Differentiate between saving properties of screens and pages.

* Add required fields to default pages layouts.

* Add _css default property to newly created screens.

* Add default code property.

* page layout / screens - app output

Co-authored-by: pngwn <pnda007@gmail.com>
2020-02-10 15:51:09 +00:00

75 lines
2.2 KiB
JavaScript

import { load, makePage } from "./testAppDef"
describe("controlFlow", () => {
it("should display simple div, with always true render function", async () => {
const { dom } = await load(
makePage({
_component: "testlib/div",
className: "my-test-class",
_id: "always_render",
})
)
expect(dom.window.document.body.children.length).toBe(1)
const child = dom.window.document.body.children[0]
expect(child.className.includes("my-test-class")).toBeTruthy()
})
it("should not display div, with always false render function", async () => {
const { dom } = await load(
makePage({
_component: "testlib/div",
className: "my-test-class",
_id: "never_render",
})
)
expect(dom.window.document.body.children.length).toBe(0)
})
it("should display 3 divs in a looped render function", async () => {
const { dom } = await load(
makePage({
_component: "testlib/div",
className: "my-test-class",
_id: "three_clones",
})
)
expect(dom.window.document.body.children.length).toBe(3)
const child0 = dom.window.document.body.children[0]
expect(child0.className.includes("my-test-class")).toBeTruthy()
const child1 = dom.window.document.body.children[1]
expect(child1.className.includes("my-test-class")).toBeTruthy()
const child2 = dom.window.document.body.children[2]
expect(child2.className.includes("my-test-class")).toBeTruthy()
})
it("should display 3 div, in a looped render, as children", async () => {
const { dom } = await load(
makePage({
_component: "testlib/div",
_children: [
{
_component: "testlib/div",
className: "my-test-class",
_id: "three_clones",
},
],
})
)
expect(dom.window.document.body.children.length).toBe(1)
const rootDiv = dom.window.document.body.children[0]
expect(rootDiv.children.length).toBe(3)
expect(rootDiv.children[0].className.includes("my-test-class")).toBeTruthy()
expect(rootDiv.children[1].className.includes("my-test-class")).toBeTruthy()
expect(rootDiv.children[2].className.includes("my-test-class")).toBeTruthy()
})
})