mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-08 04:55:06 +09:00
49 lines
1.1 KiB
TypeScript
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: [],
|
|
},
|
|
]);
|
|
});
|
|
});
|