File tree Expand file tree Collapse file tree 3 files changed +73
-5
lines changed
Expand file tree Collapse file tree 3 files changed +73
-5
lines changed Original file line number Diff line number Diff line change 11import { async , TestBed } from '@angular/core/testing' ;
2- import { IonicModule } from 'ionic-angular' ;
2+ import { IonicModule , Platform } from 'ionic-angular' ;
33
44import { StatusBar } from '@ionic-native/status-bar' ;
55import { SplashScreen } from '@ionic-native/splash-screen' ;
66
77import { MyApp } from './app.component' ;
8+ import { PlatformMock } from '../../test-config/mocks-ionic' ;
89
910describe ( 'MyApp Component' , ( ) => {
1011 let fixture ;
@@ -18,7 +19,8 @@ describe('MyApp Component', () => {
1819 ] ,
1920 providers : [
2021 StatusBar ,
21- SplashScreen
22+ SplashScreen ,
23+ { provide : Platform , useClass : PlatformMock }
2224 ]
2325 } )
2426 } ) ) ;
Original file line number Diff line number Diff line change 11import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
22import { By } from '@angular/platform-browser' ;
33import { DebugElement } from '@angular/core' ;
4- import { Page1 } from "./page1" ;
5- import { IonicModule , NavController } from "ionic-angular/index" ;
4+ import { Page1 } from './page1' ;
5+ import { IonicModule , Platform , NavController } from 'ionic-angular/index' ;
6+ import { PlatformMock } from '../../../test-config/mocks-ionic' ;
67
78describe ( 'Page1' , function ( ) {
89 let de : DebugElement ;
@@ -16,7 +17,8 @@ describe('Page1', function () {
1617 IonicModule . forRoot ( Page1 )
1718 ] ,
1819 providers : [
19- NavController
20+ NavController ,
21+ { provide : Platform , useClass : PlatformMock }
2022 ]
2123 } ) ;
2224 } ) ) ;
Original file line number Diff line number Diff line change 1+ export class PlatformMock {
2+ public ready ( ) : Promise < { String } > {
3+ return new Promise ( ( resolve ) => {
4+ resolve ( 'READY' ) ;
5+ } ) ;
6+ }
7+
8+ public getQueryParam ( ) {
9+ return true ;
10+ }
11+
12+ public registerBackButtonAction ( fn : Function , priority ?: number ) : Function {
13+ return ( ( ) => true ) ;
14+ }
15+
16+ public hasFocus ( ele : HTMLElement ) : boolean {
17+ return true ;
18+ }
19+
20+ public doc ( ) : HTMLDocument {
21+ return document ;
22+ }
23+
24+ public is ( ) : boolean {
25+ return true ;
26+ }
27+
28+ public getElementComputedStyle ( container : any ) : any {
29+ return {
30+ paddingLeft : '10' ,
31+ paddingTop : '10' ,
32+ paddingRight : '10' ,
33+ paddingBottom : '10' ,
34+ } ;
35+ }
36+
37+ public onResize ( callback : any ) {
38+ return callback ;
39+ }
40+
41+ public registerListener ( ele : any , eventName : string , callback : any ) : Function {
42+ return ( ( ) => true ) ;
43+ }
44+
45+ public win ( ) : Window {
46+ return window ;
47+ }
48+
49+ public raf ( callback : any ) : number {
50+ return 1 ;
51+ }
52+
53+ public timeout ( callback : any , timer : number ) : any {
54+ return setTimeout ( callback , timer ) ;
55+ }
56+
57+ public cancelTimeout ( id : any ) {
58+ // do nothing
59+ }
60+
61+ public getActiveElement ( ) : any {
62+ return document [ 'activeElement' ] ;
63+ }
64+ }
You can’t perform that action at this time.
0 commit comments