@trackunit/react-test-setup 1.0.16 → 1.0.17-alpha-b79b85624a2.0
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 +38 -98
- package/index.esm.js +38 -98
- package/package.json +1 -1
- package/src/setupCanvasMock.d.ts +4 -2
- package/src/setupCanvasMockImpl.d.ts +9 -0
- package/src/setupGoogleMaps.d.ts +2 -2
- package/src/setupGoogleMapsImpl.d.ts +10 -0
- package/src/setupHelmetMock.d.ts +12 -2
- package/src/setupHelmetMockImpl.d.ts +10 -0
- package/src/setupReactVirtualizedAutoSizer.d.ts +5 -4
- package/src/setupReactVirtualizedAutoSizerImpl.d.ts +11 -0
- package/src/setupTanstackReactVirtualize.d.ts +5 -4
- package/src/setupTanstackReactVirtualizeImpl.d.ts +11 -0
package/index.cjs.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
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');
|
|
7
4
|
require('@testing-library/jest-dom');
|
|
8
5
|
var react = require('@testing-library/react');
|
|
9
6
|
var polyfill = require('@js-temporal/polyfill');
|
|
@@ -12,8 +9,10 @@ var web = require('@react-spring/web');
|
|
|
12
9
|
/**
|
|
13
10
|
* Sets up a mock implementation for HTML Canvas API in testing environments.
|
|
14
11
|
*
|
|
15
|
-
* This function
|
|
16
|
-
*
|
|
12
|
+
* This function delegates to the implementation in setupCanvasMockImpl.ts to provide
|
|
13
|
+
* a mock implementation of the HTML Canvas API using jest-canvas-mock, allowing tests
|
|
14
|
+
* to run without requiring a real DOM canvas.
|
|
15
|
+
*
|
|
17
16
|
* Useful for testing components that use canvas rendering.
|
|
18
17
|
*
|
|
19
18
|
* @example
|
|
@@ -23,8 +22,8 @@ var web = require('@react-spring/web');
|
|
|
23
22
|
* setupCanvasMock();
|
|
24
23
|
*/
|
|
25
24
|
const setupCanvasMock = () => {
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
27
|
-
require("
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
26
|
+
require("./setupCanvasMockImpl").setupCanvasMock();
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
/**
|
|
@@ -46,12 +45,11 @@ const setupFailOnConsole = (overrides = {}) => {
|
|
|
46
45
|
});
|
|
47
46
|
};
|
|
48
47
|
|
|
49
|
-
const getPlacePredictionsMock = jest.fn();
|
|
50
48
|
/**
|
|
51
49
|
* Sets up mocks for Google Maps API and @vis.gl/react-google-maps components in testing environments.
|
|
52
50
|
*
|
|
53
|
-
* This function
|
|
54
|
-
*
|
|
51
|
+
* This function delegates to the implementation in setupGoogleMapsImpl.tsx to configure
|
|
52
|
+
* mock implementations of Maps, Markers, Geocoder, geometry functions, and places services,
|
|
55
53
|
* allowing tests of map-dependent components to run without requiring the actual Google Maps API.
|
|
56
54
|
*
|
|
57
55
|
* Key features:
|
|
@@ -67,70 +65,27 @@ const getPlacePredictionsMock = jest.fn();
|
|
|
67
65
|
* setupGoogleMaps();
|
|
68
66
|
*/
|
|
69
67
|
const setupGoogleMaps = () => {
|
|
70
|
-
//
|
|
71
|
-
|
|
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
|
-
});
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
69
|
+
require("./setupGoogleMapsImpl").setupGoogleMaps();
|
|
123
70
|
};
|
|
124
71
|
|
|
125
72
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
73
|
+
* Sets up mocks for react-helmet-async in testing environments.
|
|
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();
|
|
128
85
|
*/
|
|
129
86
|
const setupHelmetMock = () => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
HelmetProvider: () => null,
|
|
133
|
-
}));
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
88
|
+
require("./setupHelmetMockImpl").setupHelmetMock();
|
|
134
89
|
};
|
|
135
90
|
|
|
136
91
|
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
|
@@ -336,10 +291,11 @@ const setupReactTestingLibrary = () => {
|
|
|
336
291
|
/**
|
|
337
292
|
* Mocks the react-virtualized-auto-sizer component for testing environments.
|
|
338
293
|
*
|
|
339
|
-
* This function
|
|
340
|
-
*
|
|
341
|
-
* container dimensions. Instead of actual dimension measurements,
|
|
342
|
-
* fixed dimensions (600x600), allowing tests to run consistently
|
|
294
|
+
* This function delegates to the implementation in setupReactVirtualizedAutoSizerImpl.ts
|
|
295
|
+
* to create a mock implementation of the AutoSizer component, which is commonly used
|
|
296
|
+
* to measure and adapt to container dimensions. Instead of actual dimension measurements,
|
|
297
|
+
* the mock provides fixed dimensions (600x600), allowing tests to run consistently
|
|
298
|
+
* without actual DOM measuring.
|
|
343
299
|
*
|
|
344
300
|
* This is especially useful for testing components that use virtualized lists or grids,
|
|
345
301
|
* as it eliminates the need for setting up complex DOM environments just to get measurements.
|
|
@@ -351,7 +307,8 @@ const setupReactTestingLibrary = () => {
|
|
|
351
307
|
* setupReactVirtualizedAutoSizer();
|
|
352
308
|
*/
|
|
353
309
|
const setupReactVirtualizedAutoSizer = () => {
|
|
354
|
-
|
|
310
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
311
|
+
require("./setupReactVirtualizedAutoSizerImpl").setupReactVirtualizedAutoSizer();
|
|
355
312
|
};
|
|
356
313
|
|
|
357
314
|
/**
|
|
@@ -372,10 +329,11 @@ const setupResizeObserver = () => {
|
|
|
372
329
|
/**
|
|
373
330
|
* Mocks the @tanstack/react-virtual library for testing environments.
|
|
374
331
|
*
|
|
375
|
-
* This function
|
|
376
|
-
* the @tanstack/react-virtual
|
|
377
|
-
* large lists and grids. The mock
|
|
378
|
-
* virtual items with deterministic sizes
|
|
332
|
+
* This function delegates to the implementation in setupTanstackReactVirtualizeImpl.ts
|
|
333
|
+
* to create a mock implementation of the useVirtualizer hook from the @tanstack/react-virtual
|
|
334
|
+
* library, which is used for efficiently rendering large lists and grids. The mock
|
|
335
|
+
* returns a simplified version that generates virtual items with deterministic sizes
|
|
336
|
+
* and provides all expected methods.
|
|
379
337
|
*
|
|
380
338
|
* Each virtual item has:
|
|
381
339
|
* - A consistent height (40px)
|
|
@@ -392,26 +350,8 @@ const setupResizeObserver = () => {
|
|
|
392
350
|
* setupTanstackReactVirtual();
|
|
393
351
|
*/
|
|
394
352
|
const setupTanstackReactVirtual = () => {
|
|
395
|
-
|
|
396
|
-
|
|
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
|
-
}));
|
|
353
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
354
|
+
require("./setupTanstackReactVirtualizeImpl").setupTanstackReactVirtual();
|
|
415
355
|
};
|
|
416
356
|
|
|
417
357
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
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';
|
|
5
2
|
import '@testing-library/jest-dom';
|
|
6
3
|
import { cleanup, act } from '@testing-library/react';
|
|
7
4
|
import { Temporal } from '@js-temporal/polyfill';
|
|
@@ -10,8 +7,10 @@ import { Globals } from '@react-spring/web';
|
|
|
10
7
|
/**
|
|
11
8
|
* Sets up a mock implementation for HTML Canvas API in testing environments.
|
|
12
9
|
*
|
|
13
|
-
* This function
|
|
14
|
-
*
|
|
10
|
+
* This function delegates to the implementation in setupCanvasMockImpl.ts to provide
|
|
11
|
+
* a mock implementation of the HTML Canvas API using jest-canvas-mock, allowing tests
|
|
12
|
+
* to run without requiring a real DOM canvas.
|
|
13
|
+
*
|
|
15
14
|
* Useful for testing components that use canvas rendering.
|
|
16
15
|
*
|
|
17
16
|
* @example
|
|
@@ -21,8 +20,8 @@ import { Globals } from '@react-spring/web';
|
|
|
21
20
|
* setupCanvasMock();
|
|
22
21
|
*/
|
|
23
22
|
const setupCanvasMock = () => {
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
25
|
-
require("
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
24
|
+
require("./setupCanvasMockImpl").setupCanvasMock();
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
/**
|
|
@@ -44,12 +43,11 @@ const setupFailOnConsole = (overrides = {}) => {
|
|
|
44
43
|
});
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
const getPlacePredictionsMock = jest.fn();
|
|
48
46
|
/**
|
|
49
47
|
* Sets up mocks for Google Maps API and @vis.gl/react-google-maps components in testing environments.
|
|
50
48
|
*
|
|
51
|
-
* This function
|
|
52
|
-
*
|
|
49
|
+
* This function delegates to the implementation in setupGoogleMapsImpl.tsx to configure
|
|
50
|
+
* mock implementations of Maps, Markers, Geocoder, geometry functions, and places services,
|
|
53
51
|
* allowing tests of map-dependent components to run without requiring the actual Google Maps API.
|
|
54
52
|
*
|
|
55
53
|
* Key features:
|
|
@@ -65,70 +63,27 @@ const getPlacePredictionsMock = jest.fn();
|
|
|
65
63
|
* setupGoogleMaps();
|
|
66
64
|
*/
|
|
67
65
|
const setupGoogleMaps = () => {
|
|
68
|
-
//
|
|
69
|
-
|
|
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
|
-
});
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
67
|
+
require("./setupGoogleMapsImpl").setupGoogleMaps();
|
|
121
68
|
};
|
|
122
69
|
|
|
123
70
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
71
|
+
* Sets up mocks for react-helmet-async in testing environments.
|
|
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();
|
|
126
83
|
*/
|
|
127
84
|
const setupHelmetMock = () => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
HelmetProvider: () => null,
|
|
131
|
-
}));
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
86
|
+
require("./setupHelmetMockImpl").setupHelmetMock();
|
|
132
87
|
};
|
|
133
88
|
|
|
134
89
|
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
|
@@ -334,10 +289,11 @@ const setupReactTestingLibrary = () => {
|
|
|
334
289
|
/**
|
|
335
290
|
* Mocks the react-virtualized-auto-sizer component for testing environments.
|
|
336
291
|
*
|
|
337
|
-
* This function
|
|
338
|
-
*
|
|
339
|
-
* container dimensions. Instead of actual dimension measurements,
|
|
340
|
-
* fixed dimensions (600x600), allowing tests to run consistently
|
|
292
|
+
* This function delegates to the implementation in setupReactVirtualizedAutoSizerImpl.ts
|
|
293
|
+
* to create a mock implementation of the AutoSizer component, which is commonly used
|
|
294
|
+
* to measure and adapt to container dimensions. Instead of actual dimension measurements,
|
|
295
|
+
* the mock provides fixed dimensions (600x600), allowing tests to run consistently
|
|
296
|
+
* without actual DOM measuring.
|
|
341
297
|
*
|
|
342
298
|
* This is especially useful for testing components that use virtualized lists or grids,
|
|
343
299
|
* as it eliminates the need for setting up complex DOM environments just to get measurements.
|
|
@@ -349,7 +305,8 @@ const setupReactTestingLibrary = () => {
|
|
|
349
305
|
* setupReactVirtualizedAutoSizer();
|
|
350
306
|
*/
|
|
351
307
|
const setupReactVirtualizedAutoSizer = () => {
|
|
352
|
-
|
|
308
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
309
|
+
require("./setupReactVirtualizedAutoSizerImpl").setupReactVirtualizedAutoSizer();
|
|
353
310
|
};
|
|
354
311
|
|
|
355
312
|
/**
|
|
@@ -370,10 +327,11 @@ const setupResizeObserver = () => {
|
|
|
370
327
|
/**
|
|
371
328
|
* Mocks the @tanstack/react-virtual library for testing environments.
|
|
372
329
|
*
|
|
373
|
-
* This function
|
|
374
|
-
* the @tanstack/react-virtual
|
|
375
|
-
* large lists and grids. The mock
|
|
376
|
-
* virtual items with deterministic sizes
|
|
330
|
+
* This function delegates to the implementation in setupTanstackReactVirtualizeImpl.ts
|
|
331
|
+
* to create a mock implementation of the useVirtualizer hook from the @tanstack/react-virtual
|
|
332
|
+
* library, which is used for efficiently rendering large lists and grids. The mock
|
|
333
|
+
* returns a simplified version that generates virtual items with deterministic sizes
|
|
334
|
+
* and provides all expected methods.
|
|
377
335
|
*
|
|
378
336
|
* Each virtual item has:
|
|
379
337
|
* - A consistent height (40px)
|
|
@@ -390,26 +348,8 @@ const setupResizeObserver = () => {
|
|
|
390
348
|
* setupTanstackReactVirtual();
|
|
391
349
|
*/
|
|
392
350
|
const setupTanstackReactVirtual = () => {
|
|
393
|
-
|
|
394
|
-
|
|
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
|
-
}));
|
|
351
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
352
|
+
require("./setupTanstackReactVirtualizeImpl").setupTanstackReactVirtual();
|
|
413
353
|
};
|
|
414
354
|
|
|
415
355
|
/* 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.
|
|
4
|
+
"version": "1.0.17-alpha-b79b85624a2.0",
|
|
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,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sets up a mock implementation for HTML Canvas API in testing environments.
|
|
3
3
|
*
|
|
4
|
-
* This function
|
|
5
|
-
*
|
|
4
|
+
* This function delegates to the implementation in setupCanvasMockImpl.ts to provide
|
|
5
|
+
* a mock implementation of the HTML Canvas API using jest-canvas-mock, allowing tests
|
|
6
|
+
* to run without requiring a real DOM canvas.
|
|
7
|
+
*
|
|
6
8
|
* Useful for testing components that use canvas rendering.
|
|
7
9
|
*
|
|
8
10
|
* @example
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
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
|
-
*
|
|
4
|
+
* This function delegates to the implementation in setupGoogleMapsImpl.tsx to configure
|
|
5
|
+
* 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:
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
package/src/setupHelmetMock.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Sets up mocks for react-helmet-async in testing environments.
|
|
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();
|
|
4
14
|
*/
|
|
5
15
|
export declare const setupHelmetMock: () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
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,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mocks the react-virtualized-auto-sizer component for testing environments.
|
|
3
3
|
*
|
|
4
|
-
* This function
|
|
5
|
-
*
|
|
6
|
-
* container dimensions. Instead of actual dimension measurements,
|
|
7
|
-
* fixed dimensions (600x600), allowing tests to run consistently
|
|
4
|
+
* This function delegates to the implementation in setupReactVirtualizedAutoSizerImpl.ts
|
|
5
|
+
* to create a mock implementation of the AutoSizer component, which is commonly used
|
|
6
|
+
* to measure and adapt to container dimensions. Instead of actual dimension measurements,
|
|
7
|
+
* the mock provides fixed dimensions (600x600), allowing tests to run consistently
|
|
8
|
+
* without actual DOM measuring.
|
|
8
9
|
*
|
|
9
10
|
* This is especially useful for testing components that use virtualized lists or grids,
|
|
10
11
|
* as it eliminates the need for setting up complex DOM environments just to get measurements.
|
|
@@ -0,0 +1,11 @@
|
|
|
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,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mocks the @tanstack/react-virtual library for testing environments.
|
|
3
3
|
*
|
|
4
|
-
* This function
|
|
5
|
-
* the @tanstack/react-virtual
|
|
6
|
-
* large lists and grids. The mock
|
|
7
|
-
* virtual items with deterministic sizes
|
|
4
|
+
* This function delegates to the implementation in setupTanstackReactVirtualizeImpl.ts
|
|
5
|
+
* to create a mock implementation of the useVirtualizer hook from the @tanstack/react-virtual
|
|
6
|
+
* library, which is used for efficiently rendering large lists and grids. The mock
|
|
7
|
+
* returns a simplified version that generates virtual items with deterministic sizes
|
|
8
|
+
* and provides all expected methods.
|
|
8
9
|
*
|
|
9
10
|
* Each virtual item has:
|
|
10
11
|
* - A consistent height (40px)
|
|
@@ -0,0 +1,11 @@
|
|
|
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;
|