Files
webstudio/apps/designer/app/shared/tree-utils/create-instance.test.ts
T

49 lines
1.1 KiB
TypeScript

import { createInstance } from "./create-instance";
describe("create instance", () => {
test("instance without id should be auto generated", () => {
const createdInstance = createInstance({
component: "Box",
});
expect(typeof createdInstance.id).toBe("string");
});
test("instance without children should be empty by default", () => {
const createdInstance = createInstance({
component: "Box",
});
expect(createdInstance.children.length).toBe(0);
});
test("instance without style should be an object after creation", () => {
const createdInstance = createInstance({
component: "Box",
});
expect(Array.isArray(createdInstance.cssRules)).toBeTruthy();
});
test("instance with children ", () => {
const createdInstance = createInstance({
component: "Box",
children: [
{
id: "1",
component: "Box",
cssRules: [],
children: [],
},
],
cssRules: [],
});
expect(createdInstance.children).toEqual([
{
id: "1",
component: "Box",
cssRules: [],
children: [],
},
]);
});
});