Skip to content

Commit c5136e6

Browse files
authored
Merge pull request #37 from johnstonbl01/master
Fix Test Warnings for Splash Screen & Status Bar
2 parents c77dee2 + 2dd881b commit c5136e6

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/app/app.component.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { StatusBar } from '@ionic-native/status-bar';
55
import { SplashScreen } from '@ionic-native/splash-screen';
66

77
import { MyApp } from './app.component';
8-
import { PlatformMock } from '../../test-config/mocks-ionic';
8+
import {
9+
PlatformMock,
10+
StatusBarMock,
11+
SplashScreenMock
12+
} from '../../test-config/mocks-ionic';
913

1014
describe('MyApp Component', () => {
1115
let fixture;
@@ -18,8 +22,8 @@ describe('MyApp Component', () => {
1822
IonicModule.forRoot(MyApp)
1923
],
2024
providers: [
21-
StatusBar,
22-
SplashScreen,
25+
{ provide: StatusBar, useClass: StatusBarMock },
26+
{ provide: SplashScreen, useClass: SplashScreenMock },
2327
{ provide: Platform, useClass: PlatformMock }
2428
]
2529
})

test-config/mocks-ionic.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { StatusBar } from '@ionic-native/status-bar';
2+
import { SplashScreen } from '@ionic-native/splash-screen';
3+
14
export class PlatformMock {
25
public ready(): Promise<{String}> {
36
return new Promise((resolve) => {
@@ -62,3 +65,15 @@ export class PlatformMock {
6265
return document['activeElement'];
6366
}
6467
}
68+
69+
export class StatusBarMock extends StatusBar {
70+
styleDefault() {
71+
return;
72+
}
73+
}
74+
75+
export class SplashScreenMock extends SplashScreen {
76+
hide() {
77+
return;
78+
}
79+
}

0 commit comments

Comments
 (0)