0
我正在嘗試爲我的組件TestComponent
編寫一個確保在用戶單擊按鈕時觸發回調的組件。但是,按鈕沒有被調用console.log(wrapper.html())
發現(雖然我可以看到它在HTML在嵌套React組件中查找含有酶的元素
按鈕是內TestComponent
使用其他組件內,如果該事項
這裏是我的測試:。
?import React from 'react';
import expect from 'expect';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import TestComponent from './test-component.jsx';
describe('<TestComponent/>',() => {
it('clicking "continue" button fires the callback',() => {
const onClickContinue = sinon.spy();
const wrapper = shallow(<TestComponent />);
console.log(wrapper.find('.btn-primary').length); // 0
console.log(wrapper.html()); // does have `.btn-primary`
// wrapper.find('.btn-primary').simulate('click');
// expect(onClickContinue.calledOnce).toBe(true);
});
});
我在做什麼錯謝謝