-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-setup.js
62 lines (50 loc) · 1.42 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* setup.js */
var jsdom = require('jsdom').jsdom;
global.document = jsdom('');
global.window = document.defaultView;
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
global[property] = document.defaultView[property];
}
});
global.window.fetch = require('whatwg-fetch');
global.window.requestAnimationFrame = callback => {
global.window.setTimeout(callback, 1000 / 60);
return 2;
};
global.window.cancelAnimationFrame = requestID => {};
global.window.localStorage = global.localStorage = {
getItem: () => null,
setItem: () => {},
removeItem: () => {},
}
global.window.scrollY = 0;
global.window.scrollX = 0;
global.window.scrollTo = (x, y) => {
global.window.scrollX = x;
global.window.scrollY = y;
}
global.document.querySelector = () => ({
clientHeight: 0,
})
global.navigator = {
userAgent: 'node.js',
language: 'en-US',
geolocation: {
getCurrentPosition: (call) => {
call({
coords: {
latitude: 52.185302899999996,
longitude: 21.0475334,
}
})
}
}
}
function AutocompleteService() {};
function getDetails() {}
function PlacesService() { return { getDetails } }
global.google = { maps: { places: { AutocompleteService, PlacesService, PlacesServiceStatus: { OK: false } } } };
// for material-ui event handler
var injectTapEventPlugin = require('react-tap-event-plugin');
injectTapEventPlugin();