add test for save endorsements method
This commit is contained in:
parent
453ddc4ca3
commit
96462fd087
2 changed files with 24 additions and 3 deletions
|
|
@ -60,7 +60,7 @@ const getDefaultState = () => ({
|
||||||
repair: null, // numerical value; how much customer owes on deductible in repair case
|
repair: null, // numerical value; how much customer owes on deductible in repair case
|
||||||
replace: null // numerical value; how much customer owes on deductible in replace case,
|
replace: null // numerical value; how much customer owes on deductible in replace case,
|
||||||
},
|
},
|
||||||
endorsementQuestionAnswers: null,
|
endorsementQuestionAnswers: null
|
||||||
},
|
},
|
||||||
customer: {
|
customer: {
|
||||||
address: {
|
address: {
|
||||||
|
|
@ -917,12 +917,11 @@ export const useMainStore = defineStore({
|
||||||
const sortedEndorsementQuestionAnswersArray = sortArrayOfObjectsByPropertyValue(endorsementQuestionAnswersArray, 'result');
|
const sortedEndorsementQuestionAnswersArray = sortArrayOfObjectsByPropertyValue(endorsementQuestionAnswersArray, 'result');
|
||||||
const haveEndorsementQuestionAnswersChanged = sortedPreviousResultsArray?.length !== sortedEndorsementQuestionAnswersArray.length
|
const haveEndorsementQuestionAnswersChanged = sortedPreviousResultsArray?.length !== sortedEndorsementQuestionAnswersArray.length
|
||||||
|| !sortedPreviousResultsArray?.every((x, i) => x.result === sortedEndorsementQuestionAnswersArray[i].result);
|
|| !sortedPreviousResultsArray?.every((x, i) => x.result === sortedEndorsementQuestionAnswersArray[i].result);
|
||||||
|
|
||||||
if (haveEndorsementQuestionAnswersChanged) {
|
if (haveEndorsementQuestionAnswersChanged) {
|
||||||
this.updateEndorsementQuestionAnswers(null);
|
this.updateEndorsementQuestionAnswers(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save new values
|
|
||||||
this.updateEndorsementQuestionAnswers(endorsementQuestionAnswersArray);
|
this.updateEndorsementQuestionAnswers(endorsementQuestionAnswersArray);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -955,4 +955,26 @@ describe('Store', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('saveEndorsementQuestionAnswers method', () => {
|
||||||
|
it('method should update endorsement question data in store', () => {
|
||||||
|
// Arrange
|
||||||
|
const questionNum = getRandomInt(1, 100);
|
||||||
|
const questionText = getRandomString(50, 300);
|
||||||
|
const selectedAnswer = getRandomString(2, 3);
|
||||||
|
const endorsementQuestionAnswersArray = [
|
||||||
|
{
|
||||||
|
questionNum,
|
||||||
|
questionText,
|
||||||
|
selectedAnswer
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// Act
|
||||||
|
store.saveEndorsementQuestionAnswers(endorsementQuestionAnswersArray);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(store.order.policy.endorsementQuestionAnswers).toEqual(endorsementQuestionAnswersArray);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue