@trackunit/react-test-setup 1.6.12 → 1.6.13

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 CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  var failOnConsole = require('jest-fail-on-console');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
- var reactGoogleMaps = require('@vis.gl/react-google-maps');
6
- var jestMocks = require('@googlemaps/jest-mocks');
7
5
  require('@okta/okta-react');
8
6
  require('@testing-library/jest-dom');
9
7
  var react = require('@testing-library/react');
@@ -92,11 +90,16 @@ const getPlacePredictionsMock = jest.fn();
92
90
  * setupGoogleMaps();
93
91
  */
94
92
  const setupGoogleMaps = () => {
93
+ // Using require here to avoid barrel file import failures
94
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
95
+ const { APILoadingStatus } = require("@vis.gl/react-google-maps");
96
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
97
+ const { initialize } = require("@googlemaps/jest-mocks");
95
98
  //To create @vis.gl/react-google-maps mock, the initialization needs to be called
96
- jestMocks.initialize();
99
+ initialize();
97
100
  jest.mock("@vis.gl/react-google-maps", () => {
98
101
  const originalModule = jest.requireActual("@vis.gl/react-google-maps");
99
- const mapOptions = { mapId: "Map 1" };
102
+ const mapOptions = { center: { lat: 0, lng: 0 }, zoom: 10 };
100
103
  const map = new google.maps.Map(document.createElement("div"), mapOptions);
101
104
  const AdvancedMarkerMock = jest.fn(props => {
102
105
  return (jsxRuntime.jsx("div", { "data-position": JSON.stringify(props.position), "data-testid": "marker", children: props.children }));
@@ -112,7 +115,7 @@ const setupGoogleMaps = () => {
112
115
  });
113
116
  return {
114
117
  ...originalModule,
115
- useApiLoadingStatus: () => reactGoogleMaps.APILoadingStatus.LOADED,
118
+ useApiLoadingStatus: () => APILoadingStatus.LOADED,
116
119
  useApiIsLoaded: () => true,
117
120
  useMap: () => map,
118
121
  AdvancedMarker: AdvancedMarkerMock,
@@ -122,7 +125,7 @@ const setupGoogleMaps = () => {
122
125
  };
123
126
  });
124
127
  beforeEach(() => {
125
- jestMocks.initialize();
128
+ initialize();
126
129
  //Adding extras
127
130
  global.window.google.maps = {
128
131
  ...global.window.google.maps,
package/index.esm.js CHANGED
@@ -1,7 +1,5 @@
1
1
  import failOnConsole from 'jest-fail-on-console';
2
2
  import { jsx, Fragment } from 'react/jsx-runtime';
3
- import { APILoadingStatus } from '@vis.gl/react-google-maps';
4
- import { initialize } from '@googlemaps/jest-mocks';
5
3
  import '@okta/okta-react';
6
4
  import '@testing-library/jest-dom';
7
5
  import { cleanup, act } from '@testing-library/react';
@@ -71,11 +69,16 @@ const getPlacePredictionsMock = jest.fn();
71
69
  * setupGoogleMaps();
72
70
  */
73
71
  const setupGoogleMaps = () => {
72
+ // Using require here to avoid barrel file import failures
73
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
74
+ const { APILoadingStatus } = require("@vis.gl/react-google-maps");
75
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
76
+ const { initialize } = require("@googlemaps/jest-mocks");
74
77
  //To create @vis.gl/react-google-maps mock, the initialization needs to be called
75
78
  initialize();
76
79
  jest.mock("@vis.gl/react-google-maps", () => {
77
80
  const originalModule = jest.requireActual("@vis.gl/react-google-maps");
78
- const mapOptions = { mapId: "Map 1" };
81
+ const mapOptions = { center: { lat: 0, lng: 0 }, zoom: 10 };
79
82
  const map = new google.maps.Map(document.createElement("div"), mapOptions);
80
83
  const AdvancedMarkerMock = jest.fn(props => {
81
84
  return (jsx("div", { "data-position": JSON.stringify(props.position), "data-testid": "marker", children: props.children }));
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.6.12",
4
+ "version": "1.6.13",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
7
7
  "engines": {