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:
Björn Otgaar
2025-12-02 14:12:35 +01:00
parent 7640c32830
commit fe13017f2d
4 changed files with 63 additions and 37 deletions

View File

@@ -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);
});
});