按钮处理程序单击错误

时间:2018-06-11 09:15:59

标签: javascript jest

我尝试在CampaignGride组件内部测试按钮处理程序,但我最后三行得到错误

it('should call onClick handler on click', () => {

    const props = {
        campaigns: testCampaigns,
        onBottomVisible: noop,
        onTopVisible: noop,
        seasonInfo: {season: '2018AW'},
        weeks: testWeeks,
        isoCalendarWeek: new CalendarWeek('2019-W52'),
        onClick: jest.fn()
    };

    const wrapper = shallow(<CampaignGrid {...props} />);
    expect(wrapper.find(ButtonAddCampaign).length).toBe(1);

    expect(props.onClick.mock.calls.length).toBe(0);
    wrapper.find(ButtonAddCampaign).simulate('click');
    expect(props.onClick.mock.calls.length).toBe(1);
    expect(props.onClick.mock.calls[0].length).toBe(1);
    expect(props.onClick.mock.calls[0][0]).toEqual(new CalendarWeek('2019-W52'));
});

0 个答案:

没有答案