File tree 2 files changed +43
-4
lines changed 2 files changed +43
-4
lines changed Original file line number Diff line number Diff line change
1
+ import { PlatformMock } from './platform' ;
2
+
3
+ describe ( 'PlatformMock' , ( ) => {
4
+ let classUnderTest ;
5
+
6
+ beforeEach ( ( ) => {
7
+ classUnderTest = PlatformMock . instance ( ) ;
8
+ } ) ;
9
+
10
+ describe ( 'dir' , ( ) => {
11
+ it ( 'should return empty string' , ( ) => {
12
+ expect ( classUnderTest . dir ( ) ) . toEqual ( '' ) ;
13
+ } ) ;
14
+ } ) ;
15
+
16
+ describe ( 'hasFocus' , ( ) => {
17
+ it ( 'should return true' , ( ) => {
18
+ expect ( classUnderTest . hasFocus ( ) ) . toBeTruthy ( ) ;
19
+ } ) ;
20
+ } ) ;
21
+
22
+ describe ( 'registerListener' , ( ) => {
23
+ let callback = ( ) => 'foo' ;
24
+
25
+ it ( 'should return function that was passed in' , ( ) => {
26
+ expect ( classUnderTest . registerListener ( callback ) . call ( ) ) . toEqual ( 'foo' ) ;
27
+ } ) ;
28
+ } ) ;
29
+ } ) ;
Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ export class PlatformMock {
26
26
'registerListener' ,
27
27
'win' ,
28
28
'getActiveElement' ,
29
- 'raf'
29
+ 'raf' ,
30
+ 'hasFocus' ,
31
+ 'getElementComputedStyle' ,
32
+ 'timeout'
30
33
] ) ;
31
34
32
35
instance . dir . and . returnValue ( '' ) ;
@@ -38,16 +41,23 @@ export class PlatformMock {
38
41
instance . lang . and . returnValue ( 'en' ) ;
39
42
instance . platforms . and . returnValue ( [ ] ) ;
40
43
instance . ready . and . returnValue ( Promise . resolve ( ) ) ;
41
- instance . registerBackButtonAction . and . returnValue ( ( ) => {
42
- } ) ;
44
+ instance . registerBackButtonAction . and . callFake ( callback => callback ) ;
45
+ instance . registerListener . and . callFake ( callback => callback ) ;
43
46
instance . url . and . returnValue ( '' ) ;
44
47
instance . version . and . returnValue ( [ ] ) ;
45
48
instance . width . and . returnValue ( 0 ) ;
46
49
instance . doc . and . returnValue ( document ) ;
47
50
instance . win . and . returnValue ( window ) ;
48
51
instance . getActiveElement . and . returnValue ( document [ 'activeElement' ] ) ;
49
52
instance . raf . and . returnValue ( 1 ) ;
50
-
53
+ instance . hasFocus . and . returnValue ( true ) ;
54
+ instance . getElementComputedStyle . and . returnValue ( {
55
+ paddingLeft : '10' ,
56
+ paddingTop : '10' ,
57
+ paddingRight : '10' ,
58
+ paddingBottom : '10'
59
+ } ) ;
60
+ instance . timeout . and . callFake ( ( callback : any , timer : number ) => setTimeout ( callback , timer ) ) ;
51
61
return instance ;
52
62
}
53
63
}
You can’t perform that action at this time.
0 commit comments