@ionic/angular#Events TypeScript Examples
The following examples show how to use
@ionic/angular#Events.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: app.component.spec.ts From actions-test with Apache License 2.0 | 5 votes |
describe('AppComponent', () => {
let eventsSpy,
menuSpy,
routerSpy,
userDataSpy,
statusBarSpy,
splashScreenSpy,
swUpdateSpy,
platformReadySpy,
platformSpy,
app,
fixture;
beforeEach(async(() => {
eventsSpy = jasmine.createSpyObj('Events', ['subscribe']);
menuSpy = jasmine.createSpyObj('MenuController', ['toggle', 'enable']);
routerSpy = jasmine.createSpyObj('Router', ['navigateByUrl']);
userDataSpy = jasmine.createSpyObj('UserData', ['isLoggedIn', 'logout']);
statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']);
splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']);
swUpdateSpy = jasmine.createSpyObj('SwUpdate', ['available', 'activateUpdate']);
platformReadySpy = Promise.resolve();
platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy });
TestBed.configureTestingModule({
declarations: [AppComponent],
imports: [IonicStorageModule.forRoot()],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{ provide: Events, useValue: eventsSpy },
{ provide: MenuController, useValue: menuSpy },
{ provide: Router, useValue: routerSpy },
{ provide: UserData, useValue: userDataSpy },
{ provide: StatusBar, useValue: statusBarSpy },
{ provide: SplashScreen, useValue: splashScreenSpy },
{ provide: SwUpdate, useValue: swUpdateSpy },
{ provide: Platform, useValue: platformSpy }
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
app = fixture.debugElement.componentInstance;
});
it('should create the app', () => {
expect(app).toBeTruthy();
});
it('should initialize the app', async () => {
expect(platformSpy.ready).toHaveBeenCalled();
await platformReadySpy;
expect(statusBarSpy.styleDefault).toHaveBeenCalled();
expect(splashScreenSpy.hide).toHaveBeenCalled();
});
});