update tests as per comments

This commit is contained in:
piyush arora committed 2022-03-30 23:54:14 +05:30
1 parent 508640de61
commit 0bf885cc6b
1 file changed
+16 -10
+16 -10
View File
@@ -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: [],
},
]);
});
});