@neo4j-nvl/react 1.2.2 → 2.0.0-1e695738

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +54 -1
  2. package/README.md +6 -6
  3. package/lib/basic-wrapper/BasicNvlWrapper.d.ts +30 -41
  4. package/lib/basic-wrapper/BasicNvlWrapper.js +116 -149
  5. package/lib/index.d.ts +5 -8
  6. package/lib/index.js +3 -3
  7. package/lib/interactive-nvl-wrapper/InteractionHandlers.d.ts +8 -8
  8. package/lib/interactive-nvl-wrapper/InteractionHandlers.js +62 -57
  9. package/lib/interactive-nvl-wrapper/InteractiveNvlWrapper.d.ts +5 -5
  10. package/lib/interactive-nvl-wrapper/InteractiveNvlWrapper.js +54 -42
  11. package/lib/interactive-nvl-wrapper/hooks.d.ts +4 -4
  12. package/lib/interactive-nvl-wrapper/hooks.js +24 -27
  13. package/lib/interactive-nvl-wrapper/types.d.ts +9 -9
  14. package/lib/interactive-nvl-wrapper/types.js +0 -1
  15. package/lib/static-picture-wrapper/StaticPictureWrapper.d.ts +15 -15
  16. package/lib/static-picture-wrapper/StaticPictureWrapper.js +71 -55
  17. package/lib/utils/constants.d.ts +1 -1
  18. package/lib/utils/constants.js +4 -2
  19. package/lib/utils/graph-comparison.d.ts +5 -5
  20. package/lib/utils/graph-comparison.js +53 -68
  21. package/lib/utils/hooks.d.ts +2 -2
  22. package/lib/utils/hooks.js +10 -11
  23. package/package.json +26 -11
  24. package/lib/__tests__/BasicNvlWrapper.test.d.ts +0 -1
  25. package/lib/__tests__/BasicNvlWrapper.test.js +0 -135
  26. package/lib/__tests__/InteractiveNvlWrapper.test.d.ts +0 -1
  27. package/lib/__tests__/InteractiveNvlWrapper.test.js +0 -392
  28. package/lib/__tests__/StaticPictureWrapper.test.d.ts +0 -1
  29. package/lib/__tests__/StaticPictureWrapper.test.js +0 -85
  30. package/lib/__tests__/index.test.d.ts +0 -1
  31. package/lib/__tests__/index.test.js +0 -8
@@ -1,392 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import NVL, { HierarchicalLayoutType } from '@neo4j-nvl/base';
3
- import { BoxSelectInteraction, ClickInteraction, DragNodeInteraction, DrawInteraction, HoverInteraction, KeyboardInteraction, LassoInteraction, PanInteraction, ZoomInteraction } from '@neo4j-nvl/interaction-handlers';
4
- import '@testing-library/jest-dom';
5
- import { render } from '@testing-library/react';
6
- import { StrictMode, act, createRef } from 'react';
7
- import { InteractiveNvlWrapper } from '../interactive-nvl-wrapper/InteractiveNvlWrapper';
8
- jest.mock('@neo4j-nvl/base');
9
- jest.mock('@neo4j-nvl/layout-workers');
10
- jest.mock('@neo4j-nvl/interaction-handlers');
11
- const MockedNVL = NVL;
12
- let mockOnInitialization;
13
- HoverInteraction.prototype.callbackMap = new Map();
14
- HoverInteraction.prototype.updateCallback = jest.fn();
15
- HoverInteraction.prototype.removeCallback = jest.fn();
16
- HoverInteraction.prototype.destroy = jest.fn();
17
- PanInteraction.prototype.callbackMap = new Map();
18
- PanInteraction.prototype.updateCallback = jest.fn();
19
- PanInteraction.prototype.removeCallback = jest.fn();
20
- PanInteraction.prototype.destroy = jest.fn();
21
- ClickInteraction.prototype.callbackMap = new Map();
22
- ClickInteraction.prototype.updateCallback = jest.fn();
23
- ClickInteraction.prototype.removeCallback = jest.fn();
24
- ClickInteraction.prototype.destroy = jest.fn();
25
- ZoomInteraction.prototype.callbackMap = new Map();
26
- ZoomInteraction.prototype.updateCallback = jest.fn();
27
- ZoomInteraction.prototype.removeCallback = jest.fn();
28
- ZoomInteraction.prototype.destroy = jest.fn();
29
- DragNodeInteraction.prototype.callbackMap = new Map();
30
- DragNodeInteraction.prototype.updateCallback = jest.fn();
31
- DragNodeInteraction.prototype.removeCallback = jest.fn();
32
- DragNodeInteraction.prototype.destroy = jest.fn();
33
- DrawInteraction.prototype.callbackMap = new Map();
34
- DrawInteraction.prototype.updateCallback = jest.fn();
35
- DrawInteraction.prototype.removeCallback = jest.fn();
36
- DrawInteraction.prototype.destroy = jest.fn();
37
- BoxSelectInteraction.prototype.callbackMap = new Map();
38
- BoxSelectInteraction.prototype.updateCallback = jest.fn();
39
- BoxSelectInteraction.prototype.removeCallback = jest.fn();
40
- BoxSelectInteraction.prototype.destroy = jest.fn();
41
- LassoInteraction.prototype.callbackMap = new Map();
42
- LassoInteraction.prototype.updateCallback = jest.fn();
43
- LassoInteraction.prototype.removeCallback = jest.fn();
44
- LassoInteraction.prototype.destroy = jest.fn();
45
- KeyboardInteraction.prototype.callbackMap = new Map();
46
- KeyboardInteraction.prototype.updateCallback = jest.fn();
47
- KeyboardInteraction.prototype.removeCallback = jest.fn();
48
- KeyboardInteraction.prototype.destroy = jest.fn();
49
- let mockDestroy;
50
- let destroyHoverInteraction;
51
- let destroyPanInteraction;
52
- describe('InteractiveNvlWrapper', () => {
53
- beforeEach(() => {
54
- jest.spyOn(NVL.prototype, 'getContainer').mockImplementation(() => document.createElement('div'));
55
- MockedNVL.mockImplementation((_container, _nodes, _rels, _options, callbacks) => {
56
- mockOnInitialization = callbacks.onInitialization;
57
- return {
58
- getContainer: () => document.createElement('div'),
59
- destroy: mockDestroy,
60
- setLayout: jest.fn(),
61
- setLayoutOptions: jest.fn(),
62
- setRenderer: jest.fn()
63
- };
64
- });
65
- mockDestroy = jest.fn();
66
- destroyHoverInteraction = jest.fn();
67
- destroyPanInteraction = jest.fn();
68
- jest.spyOn(NVL.prototype, 'destroy').mockImplementation(mockDestroy);
69
- jest.spyOn(HoverInteraction.prototype, 'destroy').mockImplementation(destroyHoverInteraction);
70
- jest.spyOn(PanInteraction.prototype, 'destroy').mockImplementation(destroyPanInteraction);
71
- jest.spyOn(ClickInteraction.prototype, 'destroy').mockImplementation(jest.fn());
72
- jest.spyOn(ZoomInteraction.prototype, 'destroy').mockImplementation(jest.fn());
73
- jest.spyOn(DragNodeInteraction.prototype, 'destroy').mockImplementation(jest.fn());
74
- jest.spyOn(DrawInteraction.prototype, 'destroy').mockImplementation(jest.fn());
75
- jest.spyOn(BoxSelectInteraction.prototype, 'destroy').mockImplementation(jest.fn());
76
- jest.spyOn(LassoInteraction.prototype, 'destroy').mockImplementation(jest.fn());
77
- jest.spyOn(KeyboardInteraction.prototype, 'destroy').mockImplementation(jest.fn());
78
- });
79
- afterEach(() => {
80
- jest.clearAllMocks();
81
- });
82
- test('initialises NVL expectedly with an empty graph object and no other properties', () => {
83
- render(_jsx("div", { children: _jsx(InteractiveNvlWrapper, { nodes: [], rels: [] }) }));
84
- expect(NVL).toHaveBeenCalledWith(expect.any(HTMLDivElement), [], [], {}, { onInitialization: mockOnInitialization });
85
- });
86
- test('initialises NVL expectedly with a graph object and properties', () => {
87
- const mockLayoutDoneFunction = jest.fn();
88
- render(_jsx(InteractiveNvlWrapper, { nodes: [{ id: '1' }, { id: '2' }], rels: [{ id: '12', from: '1', to: '2' }], layout: HierarchicalLayoutType, layoutOptions: { enableCytoscape: true }, nvlOptions: { renderer: 'canvas' }, nvlCallbacks: { onLayoutDone: mockLayoutDoneFunction } }));
89
- act(() => {
90
- mockOnInitialization?.();
91
- });
92
- expect(NVL).toHaveBeenCalledWith(expect.any(HTMLDivElement), [{ id: '1' }, { id: '2' }], [{ id: '12', from: '1', to: '2' }], { renderer: 'canvas', layout: HierarchicalLayoutType, layoutOptions: { enableCytoscape: true } }, {
93
- onLayoutDone: mockLayoutDoneFunction,
94
- onInitialization: mockOnInitialization
95
- });
96
- });
97
- test('initialises expected interaction handlers with correct options', () => {
98
- const myNvlRef = createRef();
99
- render(_jsx(InteractiveNvlWrapper, { nodes: [], rels: [], ref: myNvlRef, mouseEventCallbacks: {
100
- onHover: true,
101
- onPan: true
102
- }, interactionOptions: {
103
- drawShadowOnHover: true
104
- } }));
105
- act(() => {
106
- mockOnInitialization?.();
107
- });
108
- expect(HoverInteraction).toHaveBeenCalledWith(myNvlRef.current, { drawShadowOnHover: true });
109
- expect(PanInteraction).toHaveBeenCalledWith(myNvlRef.current, { drawShadowOnHover: true });
110
- expect(HoverInteraction).toHaveBeenCalledTimes(1);
111
- expect(PanInteraction).toHaveBeenCalledTimes(1);
112
- expect(ClickInteraction).not.toHaveBeenCalled();
113
- expect(DragNodeInteraction).not.toHaveBeenCalled();
114
- expect(DrawInteraction).not.toHaveBeenCalled();
115
- expect(ZoomInteraction).not.toHaveBeenCalled();
116
- expect(BoxSelectInteraction).not.toHaveBeenCalled();
117
- expect(LassoInteraction).not.toHaveBeenCalled();
118
- expect(KeyboardInteraction).not.toHaveBeenCalled();
119
- });
120
- test.each([
121
- {
122
- name: 'HoverInteraction',
123
- InteractionClass: HoverInteraction,
124
- callback: { onHover: jest.fn() },
125
- options: { drawShadowOnHover: true }
126
- },
127
- {
128
- name: 'ClickInteraction with onCanvasClick',
129
- InteractionClass: ClickInteraction,
130
- callback: { onCanvasClick: jest.fn() },
131
- options: { selectOnClick: false }
132
- },
133
- {
134
- name: 'ClickInteraction with onCanvasDoubleClick',
135
- InteractionClass: ClickInteraction,
136
- callback: { onCanvasDoubleClick: jest.fn() },
137
- options: { selectOnClick: false }
138
- },
139
- {
140
- name: 'ClickInteraction with onCanvasRightClick',
141
- InteractionClass: ClickInteraction,
142
- callback: { onCanvasRightClick: jest.fn() },
143
- options: { selectOnClick: false }
144
- },
145
- {
146
- name: 'ClickInteraction with onNodeClick',
147
- InteractionClass: ClickInteraction,
148
- callback: { onNodeClick: jest.fn() },
149
- options: { selectOnClick: true }
150
- },
151
- {
152
- name: 'ClickInteraction with onNodeDoubleClick',
153
- InteractionClass: ClickInteraction,
154
- callback: { onNodeDoubleClick: jest.fn() },
155
- options: { selectOnClick: false }
156
- },
157
- {
158
- name: 'ClickInteraction with onNodeRightClick',
159
- InteractionClass: ClickInteraction,
160
- callback: { onNodeRightClick: jest.fn() },
161
- options: { selectOnClick: false }
162
- },
163
- {
164
- name: 'ClickInteraction with onRelationshipClick',
165
- InteractionClass: ClickInteraction,
166
- callback: { onRelationshipClick: jest.fn() },
167
- options: { selectOnClick: false }
168
- },
169
- {
170
- name: 'ClickInteraction with onRelationshipDoubleClick',
171
- InteractionClass: ClickInteraction,
172
- callback: { onRelationshipDoubleClick: jest.fn() },
173
- options: { selectOnClick: false }
174
- },
175
- {
176
- name: 'ClickInteraction with onRelationshipRightClick',
177
- InteractionClass: ClickInteraction,
178
- callback: { onRelationshipRightClick: jest.fn() },
179
- options: { selectOnClick: false }
180
- },
181
- {
182
- name: 'PanInteraction',
183
- InteractionClass: PanInteraction,
184
- callback: { onPan: jest.fn() },
185
- options: {}
186
- },
187
- {
188
- name: 'ZoomInteraction',
189
- InteractionClass: ZoomInteraction,
190
- callback: { onZoom: jest.fn() },
191
- options: {}
192
- },
193
- {
194
- name: 'DragNodeInteraction with onDrag',
195
- InteractionClass: DragNodeInteraction,
196
- callback: { onDrag: jest.fn() },
197
- options: { selectOnRelease: false }
198
- },
199
- {
200
- name: 'DragNodeInteraction with onDragStart',
201
- InteractionClass: DragNodeInteraction,
202
- callback: { onDragStart: jest.fn() },
203
- options: {}
204
- },
205
- {
206
- name: 'DragNodeInteraction with onDragEnd',
207
- InteractionClass: DragNodeInteraction,
208
- callback: { onDragEnd: jest.fn() },
209
- options: {}
210
- },
211
- {
212
- name: 'DrawInteraction with onHoverNodeMargin',
213
- InteractionClass: DrawInteraction,
214
- callback: { onHoverNodeMargin: jest.fn() },
215
- options: { excludeNodeMargin: false }
216
- },
217
- {
218
- name: 'DrawInteraction with onDrawStarted',
219
- InteractionClass: DrawInteraction,
220
- callback: { onDrawStarted: jest.fn() },
221
- options: {}
222
- },
223
- {
224
- name: 'DrawInteraction with onDrawEnded',
225
- InteractionClass: DrawInteraction,
226
- callback: { onDrawEnded: jest.fn() },
227
- options: {}
228
- },
229
- {
230
- name: 'BoxSelectInteraction with onBoxStarted',
231
- InteractionClass: BoxSelectInteraction,
232
- callback: { onBoxStarted: jest.fn() },
233
- options: {}
234
- },
235
- {
236
- name: 'BoxSelectInteraction with onBoxSelect',
237
- InteractionClass: BoxSelectInteraction,
238
- callback: { onBoxSelect: jest.fn() },
239
- options: {}
240
- },
241
- {
242
- name: 'LassoInteraction with onLassoStarted',
243
- InteractionClass: LassoInteraction,
244
- callback: { onLassoStarted: jest.fn() },
245
- options: {}
246
- },
247
- {
248
- name: 'LassoInteraction with onLassoSelect',
249
- InteractionClass: LassoInteraction,
250
- callback: { onLassoSelect: jest.fn() },
251
- options: {}
252
- }
253
- ])('initialises $name when its callback is provided', ({ InteractionClass, callback, options }) => {
254
- const myNvlRef = createRef();
255
- render(_jsx(InteractiveNvlWrapper, { nodes: [], rels: [], ref: myNvlRef, mouseEventCallbacks: callback, interactionOptions: options }));
256
- act(() => {
257
- mockOnInitialization?.();
258
- });
259
- expect(InteractionClass).toHaveBeenCalledWith(myNvlRef.current, options);
260
- expect(InteractionClass).toHaveBeenCalledTimes(1);
261
- });
262
- test.each([
263
- {
264
- name: 'KeyboardInteraction with onKeyDown',
265
- callback: { onKeyDown: jest.fn() }
266
- },
267
- {
268
- name: 'KeyboardInteraction with onKeyUp',
269
- callback: { onKeyUp: jest.fn() }
270
- },
271
- {
272
- name: 'KeyboardInteraction with onNodeFocus',
273
- callback: { onNodeFocus: jest.fn() }
274
- },
275
- {
276
- name: 'KeyboardInteraction with onNodeBlur',
277
- callback: { onNodeBlur: jest.fn() }
278
- },
279
- {
280
- name: 'KeyboardInteraction with onRelationshipFocus',
281
- callback: { onRelationshipFocus: jest.fn() }
282
- },
283
- {
284
- name: 'KeyboardInteraction with onRelationshipBlur',
285
- callback: { onRelationshipBlur: jest.fn() }
286
- },
287
- {
288
- name: 'KeyboardInteraction with onCanvasFocus',
289
- callback: { onCanvasFocus: jest.fn() }
290
- },
291
- {
292
- name: 'KeyboardInteraction with onCanvasBlur',
293
- callback: { onCanvasBlur: jest.fn() }
294
- }
295
- ])('initialises $name when its callback is provided', ({ callback }) => {
296
- const myNvlRef = createRef();
297
- render(_jsx(InteractiveNvlWrapper, { nodes: [], rels: [], ref: myNvlRef, keyboardEventCallbacks: callback }));
298
- act(() => {
299
- mockOnInitialization?.();
300
- });
301
- expect(KeyboardInteraction).toHaveBeenCalledWith(myNvlRef.current, expect.objectContaining({}));
302
- expect(KeyboardInteraction).toHaveBeenCalledTimes(1);
303
- });
304
- test('does not attempt to initialize interaction handlers if NVL container is not available', () => {
305
- const myNvlRef = createRef();
306
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
307
- // @ts-expect-error
308
- jest.spyOn(NVL.prototype, 'getContainer').mockImplementation(() => null);
309
- render(_jsx(InteractiveNvlWrapper, { nodes: [], rels: [], ref: myNvlRef, mouseEventCallbacks: {
310
- onHover: true
311
- }, interactionOptions: {
312
- drawShadowOnHover: true
313
- } }));
314
- expect(HoverInteraction).not.toHaveBeenCalled();
315
- expect(NVL).toHaveBeenCalledTimes(1);
316
- });
317
- test('destroys NVL and active interaction handlers on unmount', () => {
318
- const { unmount } = render(_jsx(InteractiveNvlWrapper, { nodes: [], rels: [], mouseEventCallbacks: {
319
- onHover: true
320
- } }));
321
- act(() => {
322
- mockOnInitialization?.();
323
- });
324
- unmount();
325
- expect(mockDestroy).toHaveBeenCalledTimes(1);
326
- expect(destroyHoverInteraction).toHaveBeenCalledTimes(1);
327
- expect(destroyPanInteraction).not.toHaveBeenCalled();
328
- });
329
- test('successfully re-initialises NVL and active interaction handlers when using React StrictMode', () => {
330
- const myNvlRef = createRef();
331
- render(_jsx(StrictMode, { children: _jsx(InteractiveNvlWrapper, { nodes: [], rels: [], ref: myNvlRef, mouseEventCallbacks: {
332
- onHover: true
333
- }, interactionOptions: {
334
- drawShadowOnHover: true
335
- } }) }));
336
- act(() => {
337
- mockOnInitialization?.();
338
- });
339
- expect(NVL).toHaveBeenCalledTimes(2);
340
- expect(HoverInteraction).toHaveBeenCalledTimes(2);
341
- expect(HoverInteraction).toHaveBeenCalledWith(myNvlRef.current, { drawShadowOnHover: true });
342
- expect(mockDestroy).toHaveBeenCalledTimes(1);
343
- expect(destroyHoverInteraction).toHaveBeenCalledTimes(1);
344
- expect(destroyPanInteraction).not.toHaveBeenCalled();
345
- expect(DragNodeInteraction).not.toHaveBeenCalled();
346
- expect(DrawInteraction).not.toHaveBeenCalled();
347
- expect(ZoomInteraction).not.toHaveBeenCalled();
348
- expect(BoxSelectInteraction).not.toHaveBeenCalled();
349
- expect(LassoInteraction).not.toHaveBeenCalled();
350
- expect(KeyboardInteraction).not.toHaveBeenCalled();
351
- });
352
- test('destroys keyboard interaction on unmount', () => {
353
- const destroyKeyboardInteraction = jest.fn();
354
- jest.spyOn(KeyboardInteraction.prototype, 'destroy').mockImplementation(destroyKeyboardInteraction);
355
- const { unmount } = render(_jsx(InteractiveNvlWrapper, { nodes: [], rels: [], keyboardEventCallbacks: {
356
- onKeyDown: true
357
- } }));
358
- act(() => {
359
- mockOnInitialization?.();
360
- });
361
- unmount();
362
- expect(destroyKeyboardInteraction).toHaveBeenCalledTimes(1);
363
- });
364
- test('also calls custom callbacks on initialization', () => {
365
- const customOnInitializationCallback = jest.fn();
366
- render(_jsx(InteractiveNvlWrapper, { nodes: [], rels: [], nvlCallbacks: { onInitialization: customOnInitializationCallback } }));
367
- act(() => {
368
- mockOnInitialization?.();
369
- });
370
- expect(customOnInitializationCallback).toHaveBeenCalledTimes(1);
371
- });
372
- test('passes zoom and pan properties to BasicNvlWrapper', () => {
373
- const setZoom = jest.fn();
374
- const setPan = jest.fn();
375
- const setZoomAndPan = jest.fn();
376
- MockedNVL.mockImplementation(() => ({
377
- getContainer: () => document.createElement('div'),
378
- destroy: jest.fn(),
379
- setLayout: jest.fn(),
380
- setLayoutOptions: jest.fn(),
381
- setNodePositions: jest.fn(),
382
- setZoom,
383
- setPan,
384
- setZoomAndPan
385
- }));
386
- render(_jsx(InteractiveNvlWrapper, { nodes: [], rels: [], zoom: 1.5, pan: { x: 10, y: 20 } }));
387
- act(() => {
388
- mockOnInitialization?.();
389
- });
390
- expect(setZoomAndPan).toHaveBeenCalledWith(1.5, 10, 20);
391
- });
392
- });
@@ -1 +0,0 @@
1
- import '@testing-library/jest-dom';
@@ -1,85 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import '@testing-library/jest-dom';
3
- import { render, waitFor } from '@testing-library/react';
4
- import { StaticPictureWrapper } from '../static-picture-wrapper/StaticPictureWrapper';
5
- jest.mock('@neo4j-nvl/base', () => {
6
- const mockNVL = jest
7
- .fn()
8
- .mockImplementation((_element, _nodes, _rels, _nvlOptions, callbacks) => {
9
- setTimeout(() => {
10
- callbacks.onLayoutDone?.();
11
- callbacks.onZoomTransitionDone?.();
12
- }, 0);
13
- return {
14
- getNodes: jest.fn().mockReturnValue([
15
- { id: '0', x: 0, y: 0 },
16
- { id: '1', x: 100, y: 100 }
17
- ]),
18
- fit: jest.fn(),
19
- getImageDataUrl: jest.fn().mockReturnValue('data:image/png;base64,...mock-png...'),
20
- getSvgDataUrl: jest.fn().mockResolvedValue('data:image/svg+xml;charset=utf-8,...mock-svg...'),
21
- destroy: jest.fn()
22
- };
23
- });
24
- return mockNVL;
25
- });
26
- const NVLMock = jest.requireMock('@neo4j-nvl/base');
27
- describe('StaticPictureWrapper - format prop support', () => {
28
- const mockNodes = [
29
- { id: '0', caption: 'Node 0' },
30
- { id: '1', caption: 'Node 1' }
31
- ];
32
- const mockRels = [{ id: '01', from: '0', to: '1', caption: 'KNOWS' }];
33
- beforeEach(() => {
34
- NVLMock.mockClear();
35
- });
36
- const getMockNVLInstance = (index = 0) => {
37
- return NVLMock.mock.results[index]?.value;
38
- };
39
- it('Should pass nodes, relationships and options to NVL constructor', () => {
40
- const mockOptions = {
41
- layout: 'hierarchical',
42
- styling: {
43
- defaultNodeColor: 'red'
44
- }
45
- };
46
- render(_jsx(StaticPictureWrapper, { nodes: mockNodes, rels: mockRels, format: "png", nvlOptions: mockOptions, width: 250, height: 250 }));
47
- expect(NVLMock).toHaveBeenCalledWith(expect.any(HTMLDivElement), mockNodes, mockRels, mockOptions, expect.any(Object));
48
- });
49
- it('Should use getSvgDataUrl for SVG format', async () => {
50
- render(_jsx(StaticPictureWrapper, { nodes: mockNodes, rels: mockRels, format: "svg" }));
51
- await waitFor(() => {
52
- const mockInstance = getMockNVLInstance();
53
- expect(mockInstance.getSvgDataUrl).toHaveBeenCalled();
54
- expect(mockInstance.getImageDataUrl).not.toHaveBeenCalled();
55
- });
56
- });
57
- it('Should use getImageDataUrl for PNG format', async () => {
58
- render(_jsx(StaticPictureWrapper, { nodes: mockNodes, rels: mockRels, format: "png" }));
59
- await waitFor(() => {
60
- const mockInstance = getMockNVLInstance();
61
- expect(mockInstance.getSvgDataUrl).not.toHaveBeenCalled();
62
- expect(mockInstance.getImageDataUrl).toHaveBeenCalled();
63
- });
64
- });
65
- it('Should triggerer re-render when format prop changes', async () => {
66
- const { rerender } = render(_jsx(StaticPictureWrapper, { nodes: mockNodes, rels: mockRels, format: "png" }));
67
- await waitFor(() => {
68
- const mockInstance = getMockNVLInstance(0);
69
- expect(mockInstance.getSvgDataUrl).not.toHaveBeenCalled();
70
- expect(mockInstance.getImageDataUrl).toHaveBeenCalledTimes(1);
71
- });
72
- rerender(_jsx(StaticPictureWrapper, { nodes: mockNodes, rels: mockRels, format: "svg" }));
73
- await waitFor(() => {
74
- const mockInstance = getMockNVLInstance(1);
75
- expect(mockInstance.getSvgDataUrl).toHaveBeenCalledTimes(1);
76
- expect(mockInstance.getImageDataUrl).not.toHaveBeenCalled();
77
- });
78
- });
79
- it('Should clean up NVL instance on unmount', () => {
80
- const { unmount } = render(_jsx(StaticPictureWrapper, { nodes: mockNodes, rels: mockRels, format: "png" }));
81
- unmount();
82
- const mockInstance = getMockNVLInstance();
83
- expect(mockInstance.destroy).toHaveBeenCalled();
84
- });
85
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import * as exportedModules from '../index';
2
- jest.mock('@neo4j-nvl/layout-workers');
3
- describe('index', () => {
4
- test('provides the expected components', () => {
5
- const modules = Object.keys(exportedModules);
6
- expect(modules).toContain('BasicNvlWrapper');
7
- });
8
- });