This mocha test describes my issue:
function closeInstance(processState, name) {
return processState.deleteIn(['processes', name, 'opened'])
}
it('closeInstance function removes the opened key from the passed process', () => {
const processState = Map({
processes: {
p1: {
id: 1,
opened: 'instance_1'
},
p2: {
id: 2,
opened: 'instance_43'
}
}
})
const nextState = closeInstance(processState, 'p1')
const expected = {
processes: {
p1: {
id: 1
},
p2: {
id: 2,
opened: 'instance_1'
}
}
}
expect(nextState.toJS()).to.deep.equal(expected)
})
Running this test produces the invalid keypath error in the closeInstance method
I believe the issue here is that Map does not deeply convert the argument.
processState.get('processes') returns a vanilla JS object, so the getIn call in closeInstance returns undefined.
Try using Immutable.fromJS to deeply convert the object.
That fixed my issue, thank you. :+1:
Merging into #635
Most helpful comment
I believe the issue here is that
Mapdoes not deeply convert the argument.processState.get('processes')returns a vanilla JS object, so thegetIncall incloseInstancereturns undefined.Try using
Immutable.fromJSto deeply convert the object.