ionic 4 unit testing example for modalcontroller

Solutions on MaxInterview for ionic 4 unit testing example for modalcontroller by the best coders in the world

showing results for - "ionic 4 unit testing example for modalcontroller"
Florencia
22 Sep 2017
1it('should display the Add photo modal when the button is clicked and logged in', () => {
2
3    let pub = {
4        phone: '123123'
5    }
6
7    component.pub = pub;
8    let authService = fixture.debugElement.injector.get(AuthService);
9
10    authService.loginWithEmail();
11    fixture.detectChanges();
12
13    expect(authService.authenticated).toBe(true);
14
15
16    let modal = fixture.debugElement.injector.get(Modal);
17    spyOn(modal, 'present');
18    debugElementArray = helper.getAllByCss(fixture, 'ion-col button');
19
20    debugElementArray[0].triggerEventHandler('click', null);
21    expect(modal.present).toHaveBeenCalled();
22
23});