forked from marmelab/react-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-setup.js
47 lines (45 loc) · 1.11 KB
/
test-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
require('raf/polyfill');
/**
* As jsDom do not support mutationobserver and
* quill requires mutationobserver, thus a shim is needed
* */
require('mutationobserver-shim');
var enzyme = require('enzyme');
var Adapter = require('enzyme-adapter-react-16');
enzyme.configure({ adapter: new Adapter() });
/**
* Mock PopperJS
*
* When using mount(), material-ui calls Popper.js, which is not compatible with JSDom
* And causes UnhandledPromiseRejectionWarning: TypeError: document.createRange is not a function
*
* @see https://github.com/FezVrasta/popper.js/issues/478
* */
jest.mock('popper.js', () => {
class Popper {
constructor() {
return {
destroy: () => {},
scheduleUpdate: () => {},
};
}
}
Popper.placements = [
'auto',
'auto-end',
'auto-start',
'bottom',
'bottom-end',
'bottom-start',
'left',
'left-end',
'left-start',
'right',
'right-end',
'right-start',
'top',
'top-end',
'top-start',
];
return Popper;
});