I use enzyme to test redux-form FIeld value depends on props. How to test Field value when passing new props. Seems that value inside component prop of Field. Anyway how to test Field from redux form, when set new props to it. is possible to test. Looks like redux form tests field value and we do no need it more, is it?
<Field
component={renderTextField}
name='name'
label={<FormattedMessage id='name' />}
/>
describe('EditDevice', () => {
let page, push, handleSubmit, init
let skip = {}
let update = sinon.stub().resolves({success: true})
let device = {
deviceType: deviceTypes.MiAccessPoint,
deviceId: 1,
lastAliveMessage: 'some text',
miConfiguration: {
fieldRange: '',
doorConfiguration: {},
},
}
beforeEach(() => page = shallow(<EditDevice
update={update}
handleSubmit={sinon.spy()}
deviceId={deviceId}
history={{push: push = sinon.spy()}}
skip={skip}
initialValues={device}
/>))
it.only('should update device fields if isLoadingInProgress turned from true to false on receiving new props', async () => {
const device = {
name: 'new name',
deviceType: deviceTypes.Tag,
version: 'new version',
deviceStatus: 'online',
}
page.setProps({isLoadingInProgress: true})
page.setProps({isLoadingInProgress: false, initialValues:{...device}})
page.update()
page.find(Field).findWhere(x => x.props().name === 'name').props().value.should.be.equal(device.name)
})