I am having the following simple unit test in React:
const prop = {name: '::name::'}
const wrapper = shallow(<Component prop={prop} />)
expect(wrapper.equals(
<div>
<div>::name::</div>
</div>
)).toEqual(true)
And I am wondering if it is correct to extract the name variable and check the expected rendered result against it:
const name = ::name::
const wrapper = shallow(<Component prop={name: name} />)
expect(wrapper.equals(
<div>
<div>{name}</div>
</div>
)).toEqual(true)
I suppose <div>::name::</div> is better than <div>{name}</div>, but I need arguments why, anyone? :}
Aucun commentaire:
Enregistrer un commentaire