-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetupTests.js
43 lines (41 loc) · 1.07 KB
/
setupTests.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
Object.defineProperties(window.HTMLElement.prototype, {
offsetLeft: {
get: function() {
return parseFloat(window.getComputedStyle(this).marginLeft) || 0;
},
},
offsetTop: {
get: function() {
return parseFloat(window.getComputedStyle(this).marginTop) || 0;
},
},
offsetHeight: {
get: function() {
return parseFloat(window.getComputedStyle(this).height) || 0;
},
},
clientHeight: {
get: function() {
return parseFloat(window.getComputedStyle(this).height) || 0;
},
},
offsetWidth: {
get: function() {
return parseFloat(window.getComputedStyle(this).width) || 0;
},
},
clientWidth: {
get: function() {
return parseFloat(window.getComputedStyle(this).width) || 0;
},
},
});
const resizeEvent = document.createEvent('Event');
resizeEvent.initEvent('resize', true, true);
Object.defineProperties(window, {
resizeTo: function(width, height) {
this.innerWidth = width || this.innerWidth;
this.innerHeight = height || this.innerHeight;
this.dispatchEvent(resizeEvent);
},
});