Created
September 2, 2017 16:23
-
-
Save leifwells/d2f5f442dcbd9617f2e3f0572db5ea76 to your computer and use it in GitHub Desktop.
Starter unit test for app.component.ts for an Ionic project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { async, TestBed } from '@angular/core/testing'; | |
| import { IonicModule, Platform } from 'ionic-angular'; | |
| import { StatusBar } from '@ionic-native/status-bar'; | |
| import { SplashScreen } from '@ionic-native/splash-screen'; | |
| import { MyApp } from './app.component'; | |
| import { | |
| PlatformMock, | |
| StatusBarMock, | |
| SplashScreenMock | |
| } from '../../test-config/mocks-ionic'; | |
| describe('MyApp Component', () => { | |
| let fixture; | |
| let component; | |
| beforeEach(async(() => { | |
| TestBed.configureTestingModule({ | |
| declarations: [MyApp], | |
| imports: [ | |
| IonicModule.forRoot(MyApp) | |
| ], | |
| providers: [ | |
| { provide: StatusBar, useClass: StatusBarMock }, | |
| { provide: SplashScreen, useClass: SplashScreenMock }, | |
| { provide: Platform, useClass: PlatformMock } | |
| ] | |
| }) | |
| })); | |
| beforeEach(() => { | |
| fixture = TestBed.createComponent(MyApp); | |
| component = fixture.componentInstance; | |
| }); | |
| it('should be created', () => { | |
| expect(component instanceof MyApp).toBe(true); | |
| }); | |
| it('should have two pages', () => { | |
| expect(component.pages.length).toBe(2); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment