|
@@ -11,22 +11,28 @@ global.localStorage = {
|
|
|
clear: jest.fn(),
|
|
|
};
|
|
|
|
|
|
+const fakeClass = class {
|
|
|
+ constructor(...args) {
|
|
|
+ this.calledWith = args;
|
|
|
+ this.listeners = new Map();
|
|
|
+ }
|
|
|
+
|
|
|
+ addListener = (name, fn) => {
|
|
|
+ const list = this.listeners.get(name) ?? [];
|
|
|
+ list.push(fn);
|
|
|
+ this.listeners.set(name, list);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
global.google = {
|
|
|
maps: {
|
|
|
- Geocoder: class {
|
|
|
- constructor() {}
|
|
|
- }
|
|
|
+ Geocoder: fakeClass,
|
|
|
+ Polyline: fakeClass,
|
|
|
+ Marker: fakeClass,
|
|
|
+ Point: fakeClass,
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-global.window = {
|
|
|
- location: {
|
|
|
- href: "http://test-url-base/",
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-global.setTimeout = jest.fn();
|
|
|
-global.clearTimeout = jest.fn();
|
|
|
+jest.useFakeTimers();
|
|
|
|
|
|
-global.setInterval = jest.fn();
|
|
|
-global.clearInterval = jest.fn();
|
|
|
+window.open = jest.fn();
|