File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
packages/taro-components-react/__tests__ Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,30 @@ process.env.TARO_ENV = 'h5'
77process . env . TARO_PLATFORM = 'web'
88process . env . SUPPORT_TARO_POLYFILL = 'disabled'
99
10+ // Mock Taro API
11+ const mockGetSystemInfo = jest . fn ( ( { success, fail } = { success : undefined , fail : undefined } ) => {
12+ try {
13+ success ?.( {
14+ windowWidth : 375 ,
15+ windowHeight : 667 ,
16+ pixelRatio : 2 ,
17+ lengthScaleRatio : 1
18+ } )
19+ } catch ( error ) {
20+ fail ?.( error )
21+ }
22+ } )
23+
24+ jest . mock ( '@tarojs/taro' , ( ) => {
25+ return {
26+ __esModule : true ,
27+ default : {
28+ getSystemInfo : mockGetSystemInfo ,
29+ } ,
30+ getSystemInfo : mockGetSystemInfo ,
31+ }
32+ } )
33+
1034// Mock Taro 组件
1135// eslint-disable-next-line react/display-name
1236jest . mock ( '@tarojs/components' , ( ) => {
You can’t perform that action at this time.
0 commit comments