lundi 4 juillet 2016

HowTo test Modal emitter in Angular2?

This is my class component:

export class GoalSettingsPage {

    public goal: Goal;

     dismiss() {
        this.viewCtrl.dismiss();
    }
}

This is my test:

  it('should emit on click', () => {

        let g = new Goal()
        let settingModal = Modal.create(GoalSettingsPage, { g:Goal });

        settingModal.subscribe(hc => {
            console.log(hc);
            expect(hc).toEqual({hasCompleted:true});
        });

        settingModal.dismiss()
    })

This is my error:

04 07 2016 16:36:48.438:ERROR [Chrome 51.0.2704 (Mac OS X 10.11.3) | Goal Settings | should emit on click]: TypeError: Cannot read property 'remove' of undefined
    at Modal.ViewController.dismiss (http://localhost:9876/absolute/var/folders/zb/tpysrhsx7hbg1dnsn4gwtqq00000gn/T/65a6294f711f882f7429da26bc12e438.browserify?2c82fe582a9911b998cb77bce54ea6804460d5cd:59060:25)

Any idea what I am doing wrong?

Aucun commentaire:

Enregistrer un commentaire