File tree Expand file tree Collapse file tree 5 files changed +76
-7
lines changed
Expand file tree Collapse file tree 5 files changed +76
-7
lines changed Original file line number Diff line number Diff line change 99 "ionic:build" : " ionic-app-scripts build" ,
1010 "ionic:serve" : " ionic-app-scripts serve" ,
1111 "test" : " karma start ./test-config/karma.conf.js" ,
12+ "test-ci" : " karma start ./test-config/karma.conf.js --single-run" ,
1213 "e2e" : " webdriver-manager update --standalone false --gecko false; protractor ./test-config/protractor.conf.js"
1314 },
1415 "dependencies" : {
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+ }
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ module.exports = {
1717 } ,
1818 {
1919 test : / \. h t m l $ / ,
20- loader : 'html-loader'
20+ loader : 'html-loader?attrs=false '
2121 } ,
2222 {
2323 test : / \. ( p n g | j p e ? g | g i f | s v g | w o f f | w o f f 2 | t t f | e o t | i c o ) $ / ,
@@ -29,7 +29,7 @@ module.exports = {
2929 plugins : [
3030 new webpack . ContextReplacementPlugin (
3131 // The (\\|\/) piece accounts for path separators in *nix and Windows
32- / a n g u l a r ( \\ | \/ ) c o r e ( \\ | \/ ) ( e s m ( \\ | \/ ) s r c | s r c ) ( \\ | \/ ) l i n k e r / ,
32+ / ( i o n i c - a n g u l a r ) | ( a n g u l a r ( \\ | \/ ) c o r e ( \\ | \/ ) @ a n g u l a r ) / ,
3333 root ( './src' ) , // location of your src
3434 { } // a map of your routes
3535 )
You can’t perform that action at this time.
0 commit comments