check if user clicked yes in ionic modal unit testing code example

Example: ionic 4 unit testing example for modalcontroller

it('should display the Add photo modal when the button is clicked and logged in', () => {

    let pub = {
        phone: '123123'
    }

    component.pub = pub;
    let authService = fixture.debugElement.injector.get(AuthService);

    authService.loginWithEmail();
    fixture.detectChanges();

    expect(authService.authenticated).toBe(true);


    let modal = fixture.debugElement.injector.get(Modal);
    spyOn(modal, 'present');
    debugElementArray = helper.getAllByCss(fixture, 'ion-col button');

    debugElementArray[0].triggerEventHandler('click', null);
    expect(modal.present).toHaveBeenCalled();

});