Modal unit testing is not working in Ionic 2

Hello,

I managed to setup a few unit tests already, but struggle with testing a Modal.
The modal shows properly from the app itself.
When running the test I receive this error:

this.addPhotoModal.present is not a function

I created this mock similarly to how I test the NavController:

export class ModalMock {

    public present(): any {
        return new Promise(function (resolve: Function): void {
            resolve();
        });
    }
}

and use it as a provider in my test like this:

{
    provide: Modal,
    useClass: ModalMock
},

Any feedback would be appreciated.

There’s not much to go on here, what does the rest of your test look like?

Hi Josh,

This is the whole test case:

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();

});