我想为后面的案例编写一个开玩笑的测试案例,因为它显示了分支覆盖50%
并指出了此代码。
render() {
const {
isExit
} = data;
const text = isExit ? 'Yes' : 'No';
或
<LabelValue label="New Line" value={isExit ? 'Yes' : 'No'} />
测试用例
it('Should display the data if API status is complete', () => {
const wrapper = shallowWithTheme(<DataPage
orderDetail={{ isExit: true}}
theme={theme}
/>);
// what to write here?
});
答案 0 :(得分:0)
expect(wrapper.text()).to.equal('Yes');
expect(wrapper.text()).to.equal('No');
答案 1 :(得分:0)
it('Should display the data if API status is complete', () => {
const wrapper = shallowWithTheme(<DataPage
orderDetail={{ isExit: true}}
theme={theme}
/>);
expect(wrapper.html()).toMatchSnapshot(); // 1st snapshot
wrapper
.setProps({orderDetail: {isExit: false}, theme})
// check your snapshot with new props :)
expect(wrapper.html()).toMatchSnapshot(); // 2nd snapshot
});
祝你好运...