【发布时间】:2019-01-30 12:56:44
【问题描述】:
下午好, 我有一个全局结构的组件文件:
class Component ...
render(){
const {array} = this.props
{!array.includes(value) ?
(<View ...props
id="myComponent"/>
....
</View>) :
(<View ...props
id="myOtherComponent"/>
....
</View>)
}
}
在我的测试文件中,我正在做类似的事情:
describe('Testing Component', () => {
test('conditional rendering', () => {
const wrapper = shallow(<Component array={[value]}/>);
expect(wrapper.find(n => n.prop('id') === "myOtherComponent").exists(true))
});
});
但是即使我修改了为数组发送的props,它总是返回我true...检查嵌套组件是否实际验证和渲染的关键字是什么...
【问题讨论】:
标签: reactjs react-native jestjs enzyme