@@ -2,51 +2,64 @@ const path = require('path')
2
2
const glob = require ( 'glob' )
3
3
4
4
global . EVENTS = [
5
- 'touchstart' ,
6
- 'touchmove' ,
7
- 'touchcancel' ,
8
- 'touchend' ,
9
- 'click' , //tap=>click
10
- 'longpress' ,
11
- 'longtap' ,
12
- 'transitionend' ,
13
- 'animationstart' ,
14
- 'animationiteration' ,
15
- 'animationend' ,
16
- 'touchforcechange'
5
+ 'touchstart' ,
6
+ 'touchmove' ,
7
+ 'touchcancel' ,
8
+ 'touchend' ,
9
+ 'click' , //tap=>click
10
+ 'longpress' ,
11
+ 'longtap' ,
12
+ 'transitionend' ,
13
+ 'animationstart' ,
14
+ 'animationiteration' ,
15
+ 'animationend' ,
16
+ 'touchforcechange'
17
17
]
18
18
19
19
global . COMPONENTS = [ ]
20
20
21
21
glob . sync ( '../../src/core/view/components/**/*/index.vue' , {
22
- nodir : true ,
23
- cwd : __dirname
22
+ nodir : true ,
23
+ cwd : __dirname
24
24
} ) . forEach ( file => {
25
- global . COMPONENTS . push ( path . basename ( path . dirname ( file ) ) )
25
+ global . COMPONENTS . push ( path . basename ( path . dirname ( file ) ) )
26
26
} )
27
27
28
28
glob . sync ( '../../src/platforms/' + process . env . UNI_PLATFORM + '/view/components/**/*/index.vue' , {
29
- nodir : true ,
30
- cwd : __dirname
29
+ nodir : true ,
30
+ cwd : __dirname
31
31
} ) . forEach ( file => {
32
- global . COMPONENTS . push ( path . basename ( path . dirname ( file ) ) )
32
+ global . COMPONENTS . push ( path . basename ( path . dirname ( file ) ) )
33
33
} )
34
34
35
35
let lastTime = 0
36
36
global . requestAnimationFrame = function ( callback , element ) {
37
- const currTime = new Date ( ) . getTime ( )
38
- const timeToCall = Math . max ( 0 , 16.7 - ( currTime - lastTime ) ) ;
39
- const id = global . setTimeout ( function ( ) {
40
- callback ( currTime + timeToCall )
41
- } , timeToCall )
42
- lastTime = currTime + timeToCall
43
- return id
37
+ const currTime = new Date ( ) . getTime ( )
38
+ const timeToCall = Math . max ( 0 , 16.7 - ( currTime - lastTime ) ) ;
39
+ const id = global . setTimeout ( function ( ) {
40
+ callback ( currTime + timeToCall )
41
+ } , timeToCall )
42
+ lastTime = currTime + timeToCall
43
+ return id
44
44
}
45
45
46
46
global . cancelAnimationFrame = function ( id ) {
47
- clearTimeout ( id )
47
+ clearTimeout ( id )
48
48
}
49
49
50
50
require ( 'jsdom-global' ) ( undefined , {
51
- pretendToBeVisual : true
51
+ pretendToBeVisual : true
52
52
} )
53
+ //fake
54
+ HTMLCanvasElement . prototype . getContext = function getContext ( ) {
55
+ return { }
56
+ }
57
+ window . Date = Date
58
+ localStorage = {
59
+ getItem : function ( key ) {
60
+ return this [ key ]
61
+ } ,
62
+ setItem : function ( key , value ) {
63
+ this [ key ] = value
64
+ }
65
+ }
0 commit comments