test: test for the actual better clone- and make sure we use the JSON stringify and parse for this since tests are weird
ref: N25B-371
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { resetFlowStore } from "../../../../test-utils/test-utils";
|
||||
import useFlowStore from '../../../../../src/pages/VisProgPage/visualProgrammingUI/VisProgStores';
|
||||
import addNode from "../../../../../src/pages/VisProgPage/visualProgrammingUI/utils/AddNode";
|
||||
|
||||
|
||||
describe('PhaseNode', () => {
|
||||
beforeEach(() => resetFlowStore());
|
||||
|
||||
it('each created phase gets its own children array (store-level)', () => {
|
||||
addNode("phase", {x:10,y:10})
|
||||
addNode("phase", {x:20,y:20})
|
||||
|
||||
const nodes = useFlowStore.getState().nodes;
|
||||
const p1 = nodes.find((x) => x.id === 'phase-1')!;
|
||||
const p2 = nodes.find((x) => x.id === 'phase-2')!;
|
||||
|
||||
// not the same reference
|
||||
expect(p1.data.children).not.toBe(p2.data.children);
|
||||
// but same initial value
|
||||
expect(p1.data.children).toEqual(p2.data.children);
|
||||
});
|
||||
});
|
||||
@@ -15,7 +15,7 @@ describe('NormNode', () => {
|
||||
});
|
||||
|
||||
function createNode(id: string, type: string, position: XYPosition, data: Record<string, unknown>, deletable?: boolean) {
|
||||
const defaultData = NodeDefaults[type as keyof typeof NodeDefaults]
|
||||
const defaultData = JSON.parse(JSON.stringify(NodeDefaults[type as keyof typeof NodeDefaults]))
|
||||
const newData = {
|
||||
id: id,
|
||||
type: type,
|
||||
|
||||
Reference in New Issue
Block a user