@trackunit/react-test-setup 1.8.83-alpha-c57027e60fa.0 → 1.8.83
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 +7 -3
- package/index.esm.js +7 -3
- package/package.json +1 -1
- package/preset.cjs.js +1 -1
- package/preset.esm.js +1 -1
- package/src/setupMapbox.d.ts +2 -0
package/index.cjs.js
CHANGED
|
@@ -112,7 +112,9 @@ const setupGoogleMaps = () => {
|
|
|
112
112
|
jest.mock("@vis.gl/react-google-maps", () => {
|
|
113
113
|
const originalModule = jest.requireActual("@vis.gl/react-google-maps");
|
|
114
114
|
const mapOptions = { center: { lat: 0, lng: 0 }, zoom: 10 };
|
|
115
|
-
const
|
|
115
|
+
const mapContainer = document.createElement("div");
|
|
116
|
+
const map = new google.maps.Map(mapContainer, mapOptions);
|
|
117
|
+
jest.spyOn(map, "getDiv").mockReturnValue(mapContainer);
|
|
116
118
|
const AdvancedMarkerMock = jest.fn(props => {
|
|
117
119
|
return (jsxRuntime.jsx("div", { "data-position": JSON.stringify(props.position), "data-testid": "marker", children: props.children }));
|
|
118
120
|
});
|
|
@@ -333,9 +335,11 @@ const createMockMapboxMap = () => {
|
|
|
333
335
|
addLayer: jest.fn(),
|
|
334
336
|
removeLayer: jest.fn(),
|
|
335
337
|
getLayer: jest.fn(() => undefined),
|
|
338
|
+
setPaintProperty: jest.fn(),
|
|
336
339
|
hasImage: jest.fn(() => false),
|
|
337
340
|
addImage: jest.fn(),
|
|
338
341
|
getCanvas: jest.fn(() => ({ style: {} })),
|
|
342
|
+
getCanvasContainer: jest.fn(() => document.createElement("div")),
|
|
339
343
|
};
|
|
340
344
|
const triggerEvent = (eventName, event) => {
|
|
341
345
|
// Fire regular listeners
|
|
@@ -411,8 +415,8 @@ const setupMapbox = () => {
|
|
|
411
415
|
});
|
|
412
416
|
return result.map;
|
|
413
417
|
};
|
|
414
|
-
const createMockMarker = () => {
|
|
415
|
-
const el = document.createElement("div");
|
|
418
|
+
const createMockMarker = (options) => {
|
|
419
|
+
const el = options?.element ?? document.createElement("div");
|
|
416
420
|
const marker = {
|
|
417
421
|
setLngLat: jest.fn(() => marker),
|
|
418
422
|
addTo: jest.fn(() => marker),
|
package/index.esm.js
CHANGED
|
@@ -91,7 +91,9 @@ const setupGoogleMaps = () => {
|
|
|
91
91
|
jest.mock("@vis.gl/react-google-maps", () => {
|
|
92
92
|
const originalModule = jest.requireActual("@vis.gl/react-google-maps");
|
|
93
93
|
const mapOptions = { center: { lat: 0, lng: 0 }, zoom: 10 };
|
|
94
|
-
const
|
|
94
|
+
const mapContainer = document.createElement("div");
|
|
95
|
+
const map = new google.maps.Map(mapContainer, mapOptions);
|
|
96
|
+
jest.spyOn(map, "getDiv").mockReturnValue(mapContainer);
|
|
95
97
|
const AdvancedMarkerMock = jest.fn(props => {
|
|
96
98
|
return (jsx("div", { "data-position": JSON.stringify(props.position), "data-testid": "marker", children: props.children }));
|
|
97
99
|
});
|
|
@@ -312,9 +314,11 @@ const createMockMapboxMap = () => {
|
|
|
312
314
|
addLayer: jest.fn(),
|
|
313
315
|
removeLayer: jest.fn(),
|
|
314
316
|
getLayer: jest.fn(() => undefined),
|
|
317
|
+
setPaintProperty: jest.fn(),
|
|
315
318
|
hasImage: jest.fn(() => false),
|
|
316
319
|
addImage: jest.fn(),
|
|
317
320
|
getCanvas: jest.fn(() => ({ style: {} })),
|
|
321
|
+
getCanvasContainer: jest.fn(() => document.createElement("div")),
|
|
318
322
|
};
|
|
319
323
|
const triggerEvent = (eventName, event) => {
|
|
320
324
|
// Fire regular listeners
|
|
@@ -390,8 +394,8 @@ const setupMapbox = () => {
|
|
|
390
394
|
});
|
|
391
395
|
return result.map;
|
|
392
396
|
};
|
|
393
|
-
const createMockMarker = () => {
|
|
394
|
-
const el = document.createElement("div");
|
|
397
|
+
const createMockMarker = (options) => {
|
|
398
|
+
const el = options?.element ?? document.createElement("div");
|
|
395
399
|
const marker = {
|
|
396
400
|
setLngLat: jest.fn(() => marker),
|
|
397
401
|
addTo: jest.fn(() => marker),
|
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.8.83
|
|
4
|
+
"version": "1.8.83",
|
|
5
5
|
"repository": "https://github.com/Trackunit/manager",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
7
7
|
"engines": {
|
package/preset.cjs.js
CHANGED
|
@@ -19,7 +19,7 @@ const irisPreset = {
|
|
|
19
19
|
"@trackunit/ui-icons/icons-sprite-micro.svg": "jest-transform-stub",
|
|
20
20
|
},
|
|
21
21
|
transformIgnorePatterns: [
|
|
22
|
-
"/node_modules/(?!.*react-dnd.*|@tanstack[/-].*|.*dnd-core.*|.*react-calendar.*|.*get-user-locale.*|.*memoize.*|.*mimic-function.*|.*@wojtekmaj[/-]date-utils.*|.*supercluster.*|.*kdbush.*|.*superjson.*|.*copy-anything.*|.*is-what.*)",
|
|
22
|
+
"/node_modules/(?!.*react-dnd.*|@tanstack[/-].*|.*dnd-core.*|.*react-calendar.*|.*get-user-locale.*|.*memoize.*|.*mimic-function.*|.*@wojtekmaj[/-]date-utils.*|.*supercluster.*|.*kdbush.*|.*superjson.*|.*copy-anything.*|.*is-what.*|.*es-toolkit.*)",
|
|
23
23
|
],
|
|
24
24
|
};
|
|
25
25
|
|
package/preset.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ const irisPreset = {
|
|
|
15
15
|
"@trackunit/ui-icons/icons-sprite-micro.svg": "jest-transform-stub",
|
|
16
16
|
},
|
|
17
17
|
transformIgnorePatterns: [
|
|
18
|
-
"/node_modules/(?!.*react-dnd.*|@tanstack[/-].*|.*dnd-core.*|.*react-calendar.*|.*get-user-locale.*|.*memoize.*|.*mimic-function.*|.*@wojtekmaj[/-]date-utils.*|.*supercluster.*|.*kdbush.*|.*superjson.*|.*copy-anything.*|.*is-what.*)",
|
|
18
|
+
"/node_modules/(?!.*react-dnd.*|@tanstack[/-].*|.*dnd-core.*|.*react-calendar.*|.*get-user-locale.*|.*memoize.*|.*mimic-function.*|.*@wojtekmaj[/-]date-utils.*|.*supercluster.*|.*kdbush.*|.*superjson.*|.*copy-anything.*|.*is-what.*|.*es-toolkit.*)",
|
|
19
19
|
],
|
|
20
20
|
};
|
|
21
21
|
|
package/src/setupMapbox.d.ts
CHANGED
|
@@ -30,9 +30,11 @@ type MockMapboxMap = {
|
|
|
30
30
|
addLayer: jest.Mock;
|
|
31
31
|
removeLayer: jest.Mock;
|
|
32
32
|
getLayer: jest.Mock;
|
|
33
|
+
setPaintProperty: jest.Mock;
|
|
33
34
|
hasImage: jest.Mock<boolean, []>;
|
|
34
35
|
addImage: jest.Mock;
|
|
35
36
|
getCanvas: jest.Mock;
|
|
37
|
+
getCanvasContainer: jest.Mock;
|
|
36
38
|
};
|
|
37
39
|
/**
|
|
38
40
|
* Return type of createMockMapboxMap - provides both the mock map
|