Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
add create instance tests
piyush arora508640de61f7
diff --git a/app/shared/tree-utils/create-instance.test.ts b/app/shared/tree-utils/create-instance.test.tsnew file mode 100644index 0000000000..70e738502e--- /dev/null+++ b/app/shared/tree-utils/create-instance.test.ts@@ -0,0 +1,42 @@+import { createInstance } from "./create-instance";++describe("create instance", () => {+ test("instance without id should be auto generated", () => {+ const createdInstance = createInstance({+ component: "Box",+ id: undefined,+ children: [],+ style: {},+ });++ // We cannot do snapshot testing here as the id will always be unique+ expect(createdInstance.id).toBeDefined();+ });++ test("instance without children should be empty by default", () => {+ const createdInstance = createInstance({+ component: "Box",+ id: undefined,+ children: undefined,+ style: {},+ });+ expect(createdInstance.children.length).toBe(0);+ });++ test("instance with children ", () => {+ const createdInstance = createInstance({+ component: "Box",+ id: undefined,+ children: [+ {+ id: "1",+ component: "Box",+ style: {},+ children: [],+ },+ ],+ style: {},+ });+ expect(createdInstance.children.length).toBe(1);+ });+});