it('should call setCampaignDate on click', function () {
let spySetCampaign = sinon.spy(wrapper.instance(), 'setCampaignDate');
let datePickers = wrapper.find('.campaign-date-tab').dive().find(Datepicker);
assert.equal(datePickers.length, 2);
console.log(datePickers);
var date = new Date();
for (let index = 0; index < datePickers.length; index++) {
datePickers.simulate('change');
sinon.assert.calledOnce(spySetCampaign.withArgs(date, 'startDate'));
}
});
我正在尝试模拟我的“更改”功能并尝试测试是否调用了“setCampaignDate”。这里的问题是find返回的我的浅组件的长度是2:
let datePickers = wrapper.find('.campaign-date-tab').dive().find(Datepicker);
尝试在“datepickers”上调用模拟时,会出现如下错误:
'Error: Method “props” is only meant to be run on a single node. 2 found instead.'.
不确定如何在节点大于 1 的组件上进行模拟。