@trackunit/react-test-setup 1.0.17-alpha-b79b85624a2.0 → 1.0.17
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.
- package/index.cjs.js +98 -38
- package/index.esm.js +98 -38
- package/package.json +1 -1
- package/src/setupCanvasMock.d.ts +2 -4
- package/src/setupGoogleMaps.d.ts +2 -2
- package/src/setupHelmetMock.d.ts +2 -12
- package/src/setupReactVirtualizedAutoSizer.d.ts +4 -5
- package/src/setupTanstackReactVirtualize.d.ts +4 -5
- package/src/setupCanvasMockImpl.d.ts +0 -9
- package/src/setupGoogleMapsImpl.d.ts +0 -10
- package/src/setupHelmetMockImpl.d.ts +0 -10
- package/src/setupReactVirtualizedAutoSizerImpl.d.ts +0 -11
- package/src/setupTanstackReactVirtualizeImpl.d.ts +0 -11
package/index.cjs.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var failOnConsole = require('jest-fail-on-console');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var reactGoogleMaps = require('@vis.gl/react-google-maps');
|
|
6
|
+
var jestMocks = require('@googlemaps/jest-mocks');
|
|
4
7
|
require('@testing-library/jest-dom');
|
|
5
8
|
var react = require('@testing-library/react');
|
|
6
9
|
var polyfill = require('@js-temporal/polyfill');
|
|
@@ -9,10 +12,8 @@ var web = require('@react-spring/web');
|
|
|
9
12
|
/**
|
|
10
13
|
* Sets up a mock implementation for HTML Canvas API in testing environments.
|
|
11
14
|
*
|
|
12
|
-
* This function
|
|
13
|
-
*
|
|
14
|
-
* to run without requiring a real DOM canvas.
|
|
15
|
-
*
|
|
15
|
+
* This function uses jest-canvas-mock to provide a mock implementation of the
|
|
16
|
+
* HTML Canvas API, allowing tests to run without requiring a real DOM canvas.
|
|
16
17
|
* Useful for testing components that use canvas rendering.
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
@@ -22,8 +23,8 @@ var web = require('@react-spring/web');
|
|
|
22
23
|
* setupCanvasMock();
|
|
23
24
|
*/
|
|
24
25
|
const setupCanvasMock = () => {
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
26
|
-
require("
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
27
|
+
require("jest-canvas-mock");
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -45,11 +46,12 @@ const setupFailOnConsole = (overrides = {}) => {
|
|
|
45
46
|
});
|
|
46
47
|
};
|
|
47
48
|
|
|
49
|
+
const getPlacePredictionsMock = jest.fn();
|
|
48
50
|
/**
|
|
49
51
|
* Sets up mocks for Google Maps API and @vis.gl/react-google-maps components in testing environments.
|
|
50
52
|
*
|
|
51
|
-
* This function
|
|
52
|
-
* mock implementations of Maps, Markers, Geocoder, geometry functions, and places services,
|
|
53
|
+
* This function mocks both the Google Maps JavaScript API and React components from @vis.gl/react-google-maps.
|
|
54
|
+
* It provides mock implementations of Maps, Markers, Geocoder, geometry functions, and places services,
|
|
53
55
|
* allowing tests of map-dependent components to run without requiring the actual Google Maps API.
|
|
54
56
|
*
|
|
55
57
|
* Key features:
|
|
@@ -65,27 +67,70 @@ const setupFailOnConsole = (overrides = {}) => {
|
|
|
65
67
|
* setupGoogleMaps();
|
|
66
68
|
*/
|
|
67
69
|
const setupGoogleMaps = () => {
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
+
//To create @vis.gl/react-google-maps mock, the initialization needs to be called
|
|
71
|
+
jestMocks.initialize();
|
|
72
|
+
jest.mock("@vis.gl/react-google-maps", () => {
|
|
73
|
+
const originalModule = jest.requireActual("@vis.gl/react-google-maps");
|
|
74
|
+
const mapOptions = { mapId: "Map 1" };
|
|
75
|
+
const map = new google.maps.Map(document.createElement("div"), mapOptions);
|
|
76
|
+
const AdvancedMarkerMock = jest.fn(props => {
|
|
77
|
+
return (jsxRuntime.jsx("div", { "data-position": JSON.stringify(props.position), "data-testid": "marker", children: props.children }));
|
|
78
|
+
});
|
|
79
|
+
const MapMock = jest.fn(props => {
|
|
80
|
+
return jsxRuntime.jsx("div", { "data-testid": "map", children: props.children });
|
|
81
|
+
});
|
|
82
|
+
const MapMarkerMock = jest.fn(props => {
|
|
83
|
+
return jsxRuntime.jsx("div", { "data-testid": "map", children: props.children });
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
...originalModule,
|
|
87
|
+
useApiLoadingStatus: () => reactGoogleMaps.APILoadingStatus.LOADED,
|
|
88
|
+
useApiIsLoaded: () => true,
|
|
89
|
+
useMap: () => map,
|
|
90
|
+
AdvancedMarker: AdvancedMarkerMock,
|
|
91
|
+
Map: MapMock,
|
|
92
|
+
Marker: MapMarkerMock,
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
jestMocks.initialize();
|
|
97
|
+
//Adding extras
|
|
98
|
+
global.window.google.maps = {
|
|
99
|
+
...global.window.google.maps,
|
|
100
|
+
Geocoder: jest.fn(),
|
|
101
|
+
geometry: {
|
|
102
|
+
...global.window.google.maps.geometry,
|
|
103
|
+
spherical: {
|
|
104
|
+
computeDistanceBetween: jest.fn(),
|
|
105
|
+
computeArea: jest.fn(),
|
|
106
|
+
computeHeading: jest.fn(),
|
|
107
|
+
computeLength: jest.fn(),
|
|
108
|
+
computeOffset: jest.fn(),
|
|
109
|
+
computeOffsetOrigin: jest.fn(),
|
|
110
|
+
computeSignedArea: jest.fn(),
|
|
111
|
+
interpolate: jest.fn(),
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
places: {
|
|
115
|
+
...global.window.google.maps.places,
|
|
116
|
+
AutocompleteService: jest.fn().mockImplementation(() => ({
|
|
117
|
+
...global.window.google.maps.places,
|
|
118
|
+
getPlacePredictions: getPlacePredictionsMock,
|
|
119
|
+
})),
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
});
|
|
70
123
|
};
|
|
71
124
|
|
|
72
125
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* This function delegates to the implementation in setupHelmetMockImpl.ts to create
|
|
76
|
-
* simple mock implementations for the Helmet and HelmetProvider components from
|
|
77
|
-
* react-helmet-async, allowing tests to run without requiring the actual library's
|
|
78
|
-
* functionality.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* // In your jest setup file
|
|
82
|
-
* import { setupHelmetMock } from '@trackunit/react-test-setup';
|
|
83
|
-
*
|
|
84
|
-
* setupHelmetMock();
|
|
126
|
+
* Mock helmet module
|
|
127
|
+
* See more details here: https://www.npmjs.com/package/react-helmet-async
|
|
85
128
|
*/
|
|
86
129
|
const setupHelmetMock = () => {
|
|
87
|
-
|
|
88
|
-
|
|
130
|
+
jest.mock("react-helmet-async", () => ({
|
|
131
|
+
Helmet: () => null,
|
|
132
|
+
HelmetProvider: () => null,
|
|
133
|
+
}));
|
|
89
134
|
};
|
|
90
135
|
|
|
91
136
|
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
|
@@ -291,11 +336,10 @@ const setupReactTestingLibrary = () => {
|
|
|
291
336
|
/**
|
|
292
337
|
* Mocks the react-virtualized-auto-sizer component for testing environments.
|
|
293
338
|
*
|
|
294
|
-
* This function
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* without actual DOM measuring.
|
|
339
|
+
* This function creates a mock implementation of the AutoSizer component from
|
|
340
|
+
* react-virtualized-auto-sizer, which is commonly used to measure and adapt to
|
|
341
|
+
* container dimensions. Instead of actual dimension measurements, the mock provides
|
|
342
|
+
* fixed dimensions (600x600), allowing tests to run consistently without actual DOM measuring.
|
|
299
343
|
*
|
|
300
344
|
* This is especially useful for testing components that use virtualized lists or grids,
|
|
301
345
|
* as it eliminates the need for setting up complex DOM environments just to get measurements.
|
|
@@ -307,8 +351,7 @@ const setupReactTestingLibrary = () => {
|
|
|
307
351
|
* setupReactVirtualizedAutoSizer();
|
|
308
352
|
*/
|
|
309
353
|
const setupReactVirtualizedAutoSizer = () => {
|
|
310
|
-
|
|
311
|
-
require("./setupReactVirtualizedAutoSizerImpl").setupReactVirtualizedAutoSizer();
|
|
354
|
+
jest.mock("react-virtualized-auto-sizer", () => ({ children }) => children({ height: 600, width: 600, scaledWidth: 600, scaledHeight: 600 }));
|
|
312
355
|
};
|
|
313
356
|
|
|
314
357
|
/**
|
|
@@ -329,11 +372,10 @@ const setupResizeObserver = () => {
|
|
|
329
372
|
/**
|
|
330
373
|
* Mocks the @tanstack/react-virtual library for testing environments.
|
|
331
374
|
*
|
|
332
|
-
* This function
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
* and provides all expected methods.
|
|
375
|
+
* This function creates a mock implementation of the useVirtualizer hook from
|
|
376
|
+
* the @tanstack/react-virtual library, which is used for efficiently rendering
|
|
377
|
+
* large lists and grids. The mock returns a simplified version that generates
|
|
378
|
+
* virtual items with deterministic sizes and provides all expected methods.
|
|
337
379
|
*
|
|
338
380
|
* Each virtual item has:
|
|
339
381
|
* - A consistent height (40px)
|
|
@@ -350,8 +392,26 @@ const setupResizeObserver = () => {
|
|
|
350
392
|
* setupTanstackReactVirtual();
|
|
351
393
|
*/
|
|
352
394
|
const setupTanstackReactVirtual = () => {
|
|
353
|
-
|
|
354
|
-
|
|
395
|
+
jest.mock("@tanstack/react-virtual", () => ({
|
|
396
|
+
useVirtualizer: ({ count }) => ({
|
|
397
|
+
getVirtualItems: () => {
|
|
398
|
+
const result = [];
|
|
399
|
+
for (let i = 0; i < count; i++) {
|
|
400
|
+
result.push({ index: i, start: i * 40, key: i, measureRef: () => { } });
|
|
401
|
+
}
|
|
402
|
+
return result;
|
|
403
|
+
},
|
|
404
|
+
getTotalSize: () => count,
|
|
405
|
+
scrollToIndex: () => { },
|
|
406
|
+
scrollToOffset: () => { },
|
|
407
|
+
scrollToAlign: () => { },
|
|
408
|
+
scrollToItem: () => { },
|
|
409
|
+
resetAfterIndex: () => { },
|
|
410
|
+
resetAfterItem: () => { },
|
|
411
|
+
scrollTo: () => { },
|
|
412
|
+
measure: () => { },
|
|
413
|
+
}),
|
|
414
|
+
}));
|
|
355
415
|
};
|
|
356
416
|
|
|
357
417
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import failOnConsole from 'jest-fail-on-console';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { APILoadingStatus } from '@vis.gl/react-google-maps';
|
|
4
|
+
import { initialize } from '@googlemaps/jest-mocks';
|
|
2
5
|
import '@testing-library/jest-dom';
|
|
3
6
|
import { cleanup, act } from '@testing-library/react';
|
|
4
7
|
import { Temporal } from '@js-temporal/polyfill';
|
|
@@ -7,10 +10,8 @@ import { Globals } from '@react-spring/web';
|
|
|
7
10
|
/**
|
|
8
11
|
* Sets up a mock implementation for HTML Canvas API in testing environments.
|
|
9
12
|
*
|
|
10
|
-
* This function
|
|
11
|
-
*
|
|
12
|
-
* to run without requiring a real DOM canvas.
|
|
13
|
-
*
|
|
13
|
+
* This function uses jest-canvas-mock to provide a mock implementation of the
|
|
14
|
+
* HTML Canvas API, allowing tests to run without requiring a real DOM canvas.
|
|
14
15
|
* Useful for testing components that use canvas rendering.
|
|
15
16
|
*
|
|
16
17
|
* @example
|
|
@@ -20,8 +21,8 @@ import { Globals } from '@react-spring/web';
|
|
|
20
21
|
* setupCanvasMock();
|
|
21
22
|
*/
|
|
22
23
|
const setupCanvasMock = () => {
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
24
|
-
require("
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
25
|
+
require("jest-canvas-mock");
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -43,11 +44,12 @@ const setupFailOnConsole = (overrides = {}) => {
|
|
|
43
44
|
});
|
|
44
45
|
};
|
|
45
46
|
|
|
47
|
+
const getPlacePredictionsMock = jest.fn();
|
|
46
48
|
/**
|
|
47
49
|
* Sets up mocks for Google Maps API and @vis.gl/react-google-maps components in testing environments.
|
|
48
50
|
*
|
|
49
|
-
* This function
|
|
50
|
-
* mock implementations of Maps, Markers, Geocoder, geometry functions, and places services,
|
|
51
|
+
* This function mocks both the Google Maps JavaScript API and React components from @vis.gl/react-google-maps.
|
|
52
|
+
* It provides mock implementations of Maps, Markers, Geocoder, geometry functions, and places services,
|
|
51
53
|
* allowing tests of map-dependent components to run without requiring the actual Google Maps API.
|
|
52
54
|
*
|
|
53
55
|
* Key features:
|
|
@@ -63,27 +65,70 @@ const setupFailOnConsole = (overrides = {}) => {
|
|
|
63
65
|
* setupGoogleMaps();
|
|
64
66
|
*/
|
|
65
67
|
const setupGoogleMaps = () => {
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
+
//To create @vis.gl/react-google-maps mock, the initialization needs to be called
|
|
69
|
+
initialize();
|
|
70
|
+
jest.mock("@vis.gl/react-google-maps", () => {
|
|
71
|
+
const originalModule = jest.requireActual("@vis.gl/react-google-maps");
|
|
72
|
+
const mapOptions = { mapId: "Map 1" };
|
|
73
|
+
const map = new google.maps.Map(document.createElement("div"), mapOptions);
|
|
74
|
+
const AdvancedMarkerMock = jest.fn(props => {
|
|
75
|
+
return (jsx("div", { "data-position": JSON.stringify(props.position), "data-testid": "marker", children: props.children }));
|
|
76
|
+
});
|
|
77
|
+
const MapMock = jest.fn(props => {
|
|
78
|
+
return jsx("div", { "data-testid": "map", children: props.children });
|
|
79
|
+
});
|
|
80
|
+
const MapMarkerMock = jest.fn(props => {
|
|
81
|
+
return jsx("div", { "data-testid": "map", children: props.children });
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
...originalModule,
|
|
85
|
+
useApiLoadingStatus: () => APILoadingStatus.LOADED,
|
|
86
|
+
useApiIsLoaded: () => true,
|
|
87
|
+
useMap: () => map,
|
|
88
|
+
AdvancedMarker: AdvancedMarkerMock,
|
|
89
|
+
Map: MapMock,
|
|
90
|
+
Marker: MapMarkerMock,
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
beforeEach(() => {
|
|
94
|
+
initialize();
|
|
95
|
+
//Adding extras
|
|
96
|
+
global.window.google.maps = {
|
|
97
|
+
...global.window.google.maps,
|
|
98
|
+
Geocoder: jest.fn(),
|
|
99
|
+
geometry: {
|
|
100
|
+
...global.window.google.maps.geometry,
|
|
101
|
+
spherical: {
|
|
102
|
+
computeDistanceBetween: jest.fn(),
|
|
103
|
+
computeArea: jest.fn(),
|
|
104
|
+
computeHeading: jest.fn(),
|
|
105
|
+
computeLength: jest.fn(),
|
|
106
|
+
computeOffset: jest.fn(),
|
|
107
|
+
computeOffsetOrigin: jest.fn(),
|
|
108
|
+
computeSignedArea: jest.fn(),
|
|
109
|
+
interpolate: jest.fn(),
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
places: {
|
|
113
|
+
...global.window.google.maps.places,
|
|
114
|
+
AutocompleteService: jest.fn().mockImplementation(() => ({
|
|
115
|
+
...global.window.google.maps.places,
|
|
116
|
+
getPlacePredictions: getPlacePredictionsMock,
|
|
117
|
+
})),
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
});
|
|
68
121
|
};
|
|
69
122
|
|
|
70
123
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* This function delegates to the implementation in setupHelmetMockImpl.ts to create
|
|
74
|
-
* simple mock implementations for the Helmet and HelmetProvider components from
|
|
75
|
-
* react-helmet-async, allowing tests to run without requiring the actual library's
|
|
76
|
-
* functionality.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* // In your jest setup file
|
|
80
|
-
* import { setupHelmetMock } from '@trackunit/react-test-setup';
|
|
81
|
-
*
|
|
82
|
-
* setupHelmetMock();
|
|
124
|
+
* Mock helmet module
|
|
125
|
+
* See more details here: https://www.npmjs.com/package/react-helmet-async
|
|
83
126
|
*/
|
|
84
127
|
const setupHelmetMock = () => {
|
|
85
|
-
|
|
86
|
-
|
|
128
|
+
jest.mock("react-helmet-async", () => ({
|
|
129
|
+
Helmet: () => null,
|
|
130
|
+
HelmetProvider: () => null,
|
|
131
|
+
}));
|
|
87
132
|
};
|
|
88
133
|
|
|
89
134
|
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
|
@@ -289,11 +334,10 @@ const setupReactTestingLibrary = () => {
|
|
|
289
334
|
/**
|
|
290
335
|
* Mocks the react-virtualized-auto-sizer component for testing environments.
|
|
291
336
|
*
|
|
292
|
-
* This function
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* without actual DOM measuring.
|
|
337
|
+
* This function creates a mock implementation of the AutoSizer component from
|
|
338
|
+
* react-virtualized-auto-sizer, which is commonly used to measure and adapt to
|
|
339
|
+
* container dimensions. Instead of actual dimension measurements, the mock provides
|
|
340
|
+
* fixed dimensions (600x600), allowing tests to run consistently without actual DOM measuring.
|
|
297
341
|
*
|
|
298
342
|
* This is especially useful for testing components that use virtualized lists or grids,
|
|
299
343
|
* as it eliminates the need for setting up complex DOM environments just to get measurements.
|
|
@@ -305,8 +349,7 @@ const setupReactTestingLibrary = () => {
|
|
|
305
349
|
* setupReactVirtualizedAutoSizer();
|
|
306
350
|
*/
|
|
307
351
|
const setupReactVirtualizedAutoSizer = () => {
|
|
308
|
-
|
|
309
|
-
require("./setupReactVirtualizedAutoSizerImpl").setupReactVirtualizedAutoSizer();
|
|
352
|
+
jest.mock("react-virtualized-auto-sizer", () => ({ children }) => children({ height: 600, width: 600, scaledWidth: 600, scaledHeight: 600 }));
|
|
310
353
|
};
|
|
311
354
|
|
|
312
355
|
/**
|
|
@@ -327,11 +370,10 @@ const setupResizeObserver = () => {
|
|
|
327
370
|
/**
|
|
328
371
|
* Mocks the @tanstack/react-virtual library for testing environments.
|
|
329
372
|
*
|
|
330
|
-
* This function
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* and provides all expected methods.
|
|
373
|
+
* This function creates a mock implementation of the useVirtualizer hook from
|
|
374
|
+
* the @tanstack/react-virtual library, which is used for efficiently rendering
|
|
375
|
+
* large lists and grids. The mock returns a simplified version that generates
|
|
376
|
+
* virtual items with deterministic sizes and provides all expected methods.
|
|
335
377
|
*
|
|
336
378
|
* Each virtual item has:
|
|
337
379
|
* - A consistent height (40px)
|
|
@@ -348,8 +390,26 @@ const setupResizeObserver = () => {
|
|
|
348
390
|
* setupTanstackReactVirtual();
|
|
349
391
|
*/
|
|
350
392
|
const setupTanstackReactVirtual = () => {
|
|
351
|
-
|
|
352
|
-
|
|
393
|
+
jest.mock("@tanstack/react-virtual", () => ({
|
|
394
|
+
useVirtualizer: ({ count }) => ({
|
|
395
|
+
getVirtualItems: () => {
|
|
396
|
+
const result = [];
|
|
397
|
+
for (let i = 0; i < count; i++) {
|
|
398
|
+
result.push({ index: i, start: i * 40, key: i, measureRef: () => { } });
|
|
399
|
+
}
|
|
400
|
+
return result;
|
|
401
|
+
},
|
|
402
|
+
getTotalSize: () => count,
|
|
403
|
+
scrollToIndex: () => { },
|
|
404
|
+
scrollToOffset: () => { },
|
|
405
|
+
scrollToAlign: () => { },
|
|
406
|
+
scrollToItem: () => { },
|
|
407
|
+
resetAfterIndex: () => { },
|
|
408
|
+
resetAfterItem: () => { },
|
|
409
|
+
scrollTo: () => { },
|
|
410
|
+
measure: () => { },
|
|
411
|
+
}),
|
|
412
|
+
}));
|
|
353
413
|
};
|
|
354
414
|
|
|
355
415
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-test-setup",
|
|
3
3
|
"description": "Test setup utilities for React applications",
|
|
4
|
-
"version": "1.0.17
|
|
4
|
+
"version": "1.0.17",
|
|
5
5
|
"repository": "https://github.com/Trackunit/manager",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
7
7
|
"engines": {
|
package/src/setupCanvasMock.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sets up a mock implementation for HTML Canvas API in testing environments.
|
|
3
3
|
*
|
|
4
|
-
* This function
|
|
5
|
-
*
|
|
6
|
-
* to run without requiring a real DOM canvas.
|
|
7
|
-
*
|
|
4
|
+
* This function uses jest-canvas-mock to provide a mock implementation of the
|
|
5
|
+
* HTML Canvas API, allowing tests to run without requiring a real DOM canvas.
|
|
8
6
|
* Useful for testing components that use canvas rendering.
|
|
9
7
|
*
|
|
10
8
|
* @example
|
package/src/setupGoogleMaps.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sets up mocks for Google Maps API and @vis.gl/react-google-maps components in testing environments.
|
|
3
3
|
*
|
|
4
|
-
* This function
|
|
5
|
-
* mock implementations of Maps, Markers, Geocoder, geometry functions, and places services,
|
|
4
|
+
* This function mocks both the Google Maps JavaScript API and React components from @vis.gl/react-google-maps.
|
|
5
|
+
* It provides mock implementations of Maps, Markers, Geocoder, geometry functions, and places services,
|
|
6
6
|
* allowing tests of map-dependent components to run without requiring the actual Google Maps API.
|
|
7
7
|
*
|
|
8
8
|
* Key features:
|
package/src/setupHelmetMock.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* This function delegates to the implementation in setupHelmetMockImpl.ts to create
|
|
5
|
-
* simple mock implementations for the Helmet and HelmetProvider components from
|
|
6
|
-
* react-helmet-async, allowing tests to run without requiring the actual library's
|
|
7
|
-
* functionality.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // In your jest setup file
|
|
11
|
-
* import { setupHelmetMock } from '@trackunit/react-test-setup';
|
|
12
|
-
*
|
|
13
|
-
* setupHelmetMock();
|
|
2
|
+
* Mock helmet module
|
|
3
|
+
* See more details here: https://www.npmjs.com/package/react-helmet-async
|
|
14
4
|
*/
|
|
15
5
|
export declare const setupHelmetMock: () => void;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mocks the react-virtualized-auto-sizer component for testing environments.
|
|
3
3
|
*
|
|
4
|
-
* This function
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* without actual DOM measuring.
|
|
4
|
+
* This function creates a mock implementation of the AutoSizer component from
|
|
5
|
+
* react-virtualized-auto-sizer, which is commonly used to measure and adapt to
|
|
6
|
+
* container dimensions. Instead of actual dimension measurements, the mock provides
|
|
7
|
+
* fixed dimensions (600x600), allowing tests to run consistently without actual DOM measuring.
|
|
9
8
|
*
|
|
10
9
|
* This is especially useful for testing components that use virtualized lists or grids,
|
|
11
10
|
* as it eliminates the need for setting up complex DOM environments just to get measurements.
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mocks the @tanstack/react-virtual library for testing environments.
|
|
3
3
|
*
|
|
4
|
-
* This function
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* and provides all expected methods.
|
|
4
|
+
* This function creates a mock implementation of the useVirtualizer hook from
|
|
5
|
+
* the @tanstack/react-virtual library, which is used for efficiently rendering
|
|
6
|
+
* large lists and grids. The mock returns a simplified version that generates
|
|
7
|
+
* virtual items with deterministic sizes and provides all expected methods.
|
|
9
8
|
*
|
|
10
9
|
* Each virtual item has:
|
|
11
10
|
* - A consistent height (40px)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implementation for HTML Canvas API mocking in testing environments.
|
|
3
|
-
*
|
|
4
|
-
* This function uses jest-canvas-mock to provide a mock implementation of the
|
|
5
|
-
* HTML Canvas API, allowing tests to run without requiring a real DOM canvas.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export declare const setupCanvasMock: () => void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implementation for Google Maps API and @vis.gl/react-google-maps mocks in testing environments.
|
|
3
|
-
*
|
|
4
|
-
* This function mocks both the Google Maps JavaScript API and React components from @vis.gl/react-google-maps.
|
|
5
|
-
* It provides mock implementations of Maps, Markers, Geocoder, geometry functions, and places services,
|
|
6
|
-
* allowing tests of map-dependent components to run without requiring the actual Google Maps API.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare const setupGoogleMaps: () => void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implementation for react-helmet-async mocking in testing environments.
|
|
3
|
-
*
|
|
4
|
-
* This function creates simple mock implementations for the Helmet and HelmetProvider
|
|
5
|
-
* components from react-helmet-async, allowing tests to run without requiring the
|
|
6
|
-
* actual library's functionality.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare const setupHelmetMock: () => void;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implementation for react-virtualized-auto-sizer component mocking in testing environments.
|
|
3
|
-
*
|
|
4
|
-
* This function creates a mock implementation of the AutoSizer component from
|
|
5
|
-
* react-virtualized-auto-sizer, which is commonly used to measure and adapt to
|
|
6
|
-
* container dimensions. Instead of actual dimension measurements, the mock provides
|
|
7
|
-
* fixed dimensions (600x600), allowing tests to run consistently without actual DOM measuring.
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare const setupReactVirtualizedAutoSizer: () => void;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implementation for @tanstack/react-virtual library mocking in testing environments.
|
|
3
|
-
*
|
|
4
|
-
* This function creates a mock implementation of the useVirtualizer hook from
|
|
5
|
-
* the @tanstack/react-virtual library, which is used for efficiently rendering
|
|
6
|
-
* large lists and grids. The mock returns a simplified version that generates
|
|
7
|
-
* virtual items with deterministic sizes and provides all expected methods.
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare const setupTanstackReactVirtual: () => void;
|