forked from bigcommerce/checkout-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-setup.ts
36 lines (30 loc) · 900 Bytes
/
jest-setup.ts
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
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { noop } from 'lodash';
configure({ adapter: new Adapter() });
// https://github.com/FezVrasta/popper.js/issues/478
if (window.document) {
document.createRange = () => ({
setStart: noop,
setEnd: noop,
commonAncestorContainer: {
nodeName: 'BODY',
ownerDocument: document,
},
} as Range);
}
window.matchMedia = jest.fn(() => ({
matches: false,
addListener: noop,
addEventListener: noop,
removeListener: noop,
removeEventListener: noop,
} as MediaQueryList));
Object.defineProperty(window.navigator, "userAgent", ((value) => ({
get() { return value; },
set(v) { value = v; }
}))(window.navigator["userAgent"]));
(global as any).__webpack_public_path__ = undefined;
beforeAll(() => {
expect.hasAssertions();
});