如何在Angular2中测试模态发射器?

时间:2016-07-04 14:45:54

标签: unit-testing model angular karma-runner

这是我的班级组成部分:

export class GoalSettingsPage {

    public goal: Goal;

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

这是我的测试:

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

这是我的错误:

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)

知道我做错了吗?

0 个答案:

没有答案