When I use setSate() method on compiled component, the state is not being set. The control is taking the state from the production code and not the state assigned from the test. Find the code below.
const wrapper = mount(<BookFlight />
wrapper.setState({ cabins: {
fields: [
{
label: 'Economy',
value: 'econ',
name: 'cabin',
type: 'radio'
},
{
label: 'Business',
value: 'business',
name: 'cabin',
type: 'radio'
},
{
label: 'First',
value: 'first',
name: 'cabin',
type: 'radio'
}
]
}})
expect(wrapper.state().cabins.fields.length).toBe(3)
Aucun commentaire:
Enregistrer un commentaire