-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmochaTestSetup.js
40 lines (34 loc) · 1020 Bytes
/
mochaTestSetup.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
import { JSDOM } from 'jsdom';
import jquery from 'jquery';
import sinon from 'sinon';
const { window } = new JSDOM('<!doctype html><html><body></body></html>', {
referrer: 'https://example.com/baz',
url: 'https://example.com/foo'
});
const $ = jquery(window);
export default function mochaTestSetup() {
global.$ = global.jQuery = $;
global.document = window.document;
global.window = window;
global.window.ww = {
detect: {
isDesktop() {
return false;
},
isMobile() {
return false;
},
isTablet() {
return false;
},
isiOS() {
return false;
},
},
};
sinon.stub(window.ww.detect, 'isDesktop').returns(false);
sinon.stub(window.ww.detect, 'isMobile').returns(false);
sinon.stub(window.ww.detect, 'isTablet').returns(false);
sinon.stub(window.ww.detect, 'isiOS').returns(false);
}
mochaTestSetup();