generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.js
62 lines (54 loc) · 1.39 KB
/
jest.setup.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
59
60
61
62
import { jest } from '@jest/globals';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import config from '@plone/volto/registry';
import { blocksConfig } from '@plone/volto/config/Blocks';
import installSlate from '@plone/volto-slate/index';
config.blocks.blocksConfig = {
...blocksConfig,
...config.blocks.blocksConfig,
};
[installSlate].reduce((acc, apply) => apply(acc), config);
const mockStore = configureStore([thunk]);
global.store = mockStore({
intl: {
locale: 'en',
messages: {},
formatMessage: jest.fn(),
},
content: {
create: {},
subrequests: [],
},
connected_data_parameters: {},
screen: {
page: {
width: 768,
},
},
});
const mockSemanticComponents = jest.requireActual('semantic-ui-react');
const mockComponents = jest.requireActual('@plone/volto/components');
jest.doMock('semantic-ui-react', () => ({
...mockSemanticComponents,
Popup: ({ content, trigger }) => {
return (
<div className="popup">
<div className="trigger">{trigger}</div>
<div className="content">{content}</div>
</div>
);
},
}));
jest.doMock('@plone/volto/components', () => {
return {
__esModule: true,
...mockComponents,
SidebarPortal: ({ children }) => <div id="sidebar">{children}</div>,
};
});
global.fetch = jest.fn(() =>
Promise.resolve({
json: () => Promise.resolve({}),
}),
);