Files
webstudio/apps/designer/app/shared/tree-utils/reparent-instance.test.ts
T
Roman Pominov 4fa48f25ed reparentInstanceMutable helper & ...
... only pass ids via postMessage & some cleanup
2022-07-28 17:11:18 +03:00

68 lines
1.4 KiB
TypeScript

import { type Instance } from "@webstudio-is/react-sdk";
import { reparentInstanceMutable } from "./reparent-instance";
describe("Reparent instance", () => {
test(`new parent`, () => {
const rootInstance: Instance = {
component: "Box",
id: "1",
cssRules: [],
children: [
{
component: "Box",
id: "2",
cssRules: [],
children: [],
},
{
component: "Box",
id: "3",
cssRules: [],
children: [
{
component: "Box",
id: "4",
cssRules: [],
children: [],
},
],
},
],
};
reparentInstanceMutable(rootInstance, "4", "2", 0);
expect(rootInstance).toMatchSnapshot();
});
test(`same parent different position`, () => {
const rootInstance: Instance = {
component: "Box",
id: "1",
cssRules: [],
children: [
{
component: "Box",
id: "2",
cssRules: [],
children: [],
},
{
component: "Box",
id: "3",
cssRules: [],
children: [],
},
{
component: "Box",
id: "4",
cssRules: [],
children: [],
},
],
};
reparentInstanceMutable(rootInstance, "2", "1", 2);
expect(rootInstance).toMatchSnapshot();
});
});