generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.setup.js
65 lines (57 loc) · 1.48 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
63
64
65
import { jest } from '@jest/globals';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { blocksConfig } from '@plone/volto/config/Blocks';
import installSlate from '@plone/volto-slate/index';
var mockSemanticComponents = jest.requireActual('semantic-ui-react');
var mockComponents = jest.requireActual('@plone/volto/components');
var config = jest.requireActual('@plone/volto/registry').default;
config.blocks.blocksConfig = {
...blocksConfig,
...config.blocks.blocksConfig,
};
jest.doMock('semantic-ui-react', () => ({
__esModule: true,
...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>,
};
});
jest.doMock('@plone/volto/registry', () =>
[installSlate].reduce((acc, apply) => apply(acc), config),
);
const mockStore = configureStore([thunk]);
global.fetch = jest.fn(() =>
Promise.resolve({
json: () => Promise.resolve({}),
}),
);
global.store = mockStore({
intl: {
locale: 'en',
messages: {},
formatMessage: jest.fn(),
},
content: {
create: {},
subrequests: [],
},
connected_data_parameters: {},
screen: {
page: {
width: 768,
},
},
});