I have a object defined as:
obj:{
name:"string",
system:"string"
}
however I am trying to update the value in mockstore as:
store.setState({
name:"Rose",
system:"Updated Dummy"
});
store.refreshState();
fixture.detectChanges();
but the value is not updating. How can I update the value and then verify that it has been updated as a part of unit testing?
store.setState updates the whole state. Therefore you need to use its feature name too to repeat the real store structure.
const featureSelector = createFeatureSelector('FEATURE_NAME_IS_HERE');
store.setState({
FEATURE_NAME_IS_HERE: { // <- adding the feature state.
name:"Rose",
system:"Updated Dummy"
},
});
store.refreshState();
fixture.detectChanges();
If you use nested reducers - then you need to nest the object to de desired child.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With