I am trying to run a existing jest test after I made momentTimezone change in the code. I believe it's because my change does another state change between the redux dispatch in the test case. I am not sure how to fix it. The expected value is appointmentGroupState.isBookingLocked is false instead of true along with this error - Below is the jest code where the error is been thrown:
Uncaught [Invariant Violation: A state mutation was detected between dispatches, in the path suggestionSearchCriteria.beginDate._locale._longDateFormat.l.
const recurViewPresenterComponentState = wrapper
.find('RecurViewPresenter')
.prop('recurViewPresenterComponentState');
const appointmentGroupState = recurViewPresenterComponentState.recurUIAppointmentGroupStates.find(
({ id }) => id === MockRecurUIComponentConfigurationMultipleApptGroups.appointmentGroups[0].uuid,
);
**expect(appointmentGroupState.isBookingLocked).toBe(true);**
});
Here is my main code snippet - momentTimezone(patientDurationDisplay.beginDateTime); I just added momentTimezone and the jest is failing.
Here is the full dispatch
const clickAppointmentTypeCard = (wrapper, apptTypeCardIndex) => {
wrapper.find('.single-appointment-type-card-list > *').at(apptTypeCardIndex).simulate('click');
};
let wrapper;
window.featureToggles = {
getAllEnabledToggles: () => [],
};
beforeEach(() => {
wrapper = mountWithTestFileI18N(
<RecurViewPresenter
recurUIComponentConfiguration={
new RecurUIComponentConfiguration({
...MockRecurUIComponentConfigurationMultipleApptGroups,
appointmentGroups: [
{
...MockRecurUIComponentConfigurationMultipleApptGroups.appointmentGroups[0],
appointmentGroupConfiguration: {
...MockRecurUIComponentConfigurationMultipleApptGroups.appointmentGroups[0]
.appointmentGroupConfiguration,
multipleAppointmentInstancesConfiguration: {
numberOfAppointmentInstancesInADay: 1,
hoursBetweenAppointmentInstancesInADay: 0,
},
},
},
MockRecurUIComponentConfigurationMultipleApptGroups.appointmentGroups[1],
],
})
}
retrieveRecurringAppointmentSuggestions={() => createMockAppointmentGroupSuggestionResult()}
onSuggestionsSelected={() => ({
bookingStatus: 'SUCCESS',
lockReleaseStatus: 'SUCCESS',
})}
/>,
);
afterEach(() => {
mockSuggestionResultsComponentSelection = {
...mockSuggestionResultsComponentSelection,
instanceIndex: 1,
};
});
```