需要使用笑话和酶来为以下功能编写测试用例的帮助...下面的asView是一个为我的案例返回视图的功能...
showRowSubView = (rowModel) => {
if (rowModel.has('tiers')) {
const record = rowModel.toJSON();
/* eslint-disable react/no-danger */
const template = asView(() =>
record.tiers.map(item => (
<table >
<tbody>
<tr>
<td>
<div className="tiersTable" dangerouslySetInnerHTML={this.returnTemplate(item)} />
</td>
</tr>
</tbody>
</table>
)),
);
return template;
}
return null;
};
答案 0 :(得分:0)
类似这样的东西:
const model = {
tiers:['a','b','c']
};
it('showRowSubView',()=>{
const wrapper = shallow(<ShowRowSubView rowModel={model }/>);
expect(wrapper).toMatchSnapshot();
});