forked from treadpit/wx_calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwx.js
44 lines (43 loc) · 896 Bytes
/
wx.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
export const noop = () => {};
export const isFn = fn => typeof fn === 'function';
let wId = 0;
global.wx = {
getSystemInfoSync: () => {
return {
model: 'iPhone 5',
pixelRatio: 2,
windowWidth: 320,
windowHeight: 504,
system: 'iOS 10.0.1',
language: 'zh',
version: '6.6.3',
screenWidth: 320,
screenHeight: 568,
SDKVersion: '2.4.0',
brand: 'devtools',
fontSizeSetting: 16,
batteryLevel: 100,
statusBarHeight: 20,
platform: 'ios'
};
}
};
global.Page = ({ data, ...rest }) => {
const page = {
data,
setData: jest.fn(function(newData, cb) {
this.data = {
...this.data,
...newData
};
cb && cb();
}),
onLoad: noop,
onReady: noop,
onUnLoad: noop,
__wxWebviewId__: wId++,
...rest
};
global.wxPageInstance = page;
return page;
};