forked from draft-js-plugins/draft-js-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testHelper.js
28 lines (22 loc) · 810 Bytes
/
testHelper.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
import chai from 'chai';
import dirtyChai from 'dirty-chai';
import hook from 'css-modules-require-hook';
import { jsdom } from 'jsdom';
process.env.NODE_ENV = 'test';
hook({
generateScopedName: '[name]__[local]___[hash:base64:5]',
});
const exposedProperties = ['window', 'navigator', 'document'];
global.document = jsdom('');
global.window = document.defaultView;
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
exposedProperties.push(property);
global[property] = document.defaultView[property];
}
});
// chaiEnzyme needs to be initialised here, so that canUseDOM is set
// to true when react-dom initialises (which chai-enzyme depends upon)
const chaiEnzyme = require('chai-enzyme');
chai.use(dirtyChai);
chai.use(chaiEnzyme());