From 0bf885cc6b32fd98bef5caf2ce751b0efecbffe9 Mon Sep 17 00:00:00 2001 From: piyush arora Date: Wed, 30 Mar 2022 23:54:14 +0530 Subject: [PATCH] update tests as per comments --- app/shared/tree-utils/create-instance.test.ts | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/app/shared/tree-utils/create-instance.test.ts b/app/shared/tree-utils/create-instance.test.ts index 70e738502e..c9501b05ac 100644 --- a/app/shared/tree-utils/create-instance.test.ts +++ b/app/shared/tree-utils/create-instance.test.ts @@ -4,29 +4,28 @@ 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(); + expect(typeof createdInstance.id).toBe("string"); }); 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 without style should be an object after creation", () => { + const createdInstance = createInstance({ + component: "Box", + }); + expect(typeof createdInstance.style).toBe("object"); + }); + test("instance with children ", () => { const createdInstance = createInstance({ component: "Box", - id: undefined, children: [ { id: "1", @@ -37,6 +36,13 @@ describe("create instance", () => { ], style: {}, }); - expect(createdInstance.children.length).toBe(1); + expect(createdInstance.children).toEqual([ + { + id: "1", + component: "Box", + style: {}, + children: [], + }, + ]); }); });