-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-mocks.js
58 lines (54 loc) · 1.58 KB
/
jest-mocks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* global jest */
/* eslint-disable unicorn/prefer-module */
jest.mock('gatsby-plugin-image', () => {
const React = require('react');
const plugin = jest.requireActual('gatsby-plugin-image');
const mockImage = ({imgClassName, ...properties}) =>
React.createElement('img', {
...properties,
className: imgClassName,
});
return {
...plugin,
GatsbyImage: jest.fn().mockImplementation(mockImage),
StaticImage: jest.fn().mockImplementation(mockImage),
};
});
jest.mock('react-helmet', () => {
const React = require('react');
const plugin = jest.requireActual('react-helmet');
const mockHelmet = ({children, ...properties}) =>
React.createElement('div', {
...properties,
className: 'mock-helmet',
}, children);
return {
...plugin,
Helmet: jest.fn().mockImplementation(mockHelmet),
};
});
jest.mock('@react-google-maps/api', () => {
const React = require('react');
const plugin = jest.requireActual('@react-google-maps/api');
const mockGoogleMap = ({children, ...properties}) =>
React.createElement('div', {
...properties,
className: 'mock-google-map',
}, children);
const mockInfoWindow = ({children, ...properties}) =>
React.createElement('div', {
...properties,
className: 'mock-info-window',
}, children);
const mockMarker = ({children, ...properties}) =>
React.createElement('div', {
...properties,
className: 'mock-marker',
}, children);
return {
...plugin,
GoogleMap: jest.fn().mockImplementation(mockGoogleMap),
InfoWindow: jest.fn().mockImplementation(mockInfoWindow),
Marker: jest.fn().mockImplementation(mockMarker),
};
});