我想为以下案例编写一个 Jest 测试用例,因为它显示分支覆盖率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?
});
最佳答案
expect(wrapper.text()).to.equal('Yes');
expect(wrapper.text()).to.equal('No');
关于reactjs - 三元运算符用 Jest 测试用例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53626077/