Fixing merge conflicts

This commit is contained in:
brydon1 2023-07-18 11:54:30 -04:00
commit e1b36a1526
7 changed files with 652 additions and 645 deletions

2
.gitignore vendored
View file

@ -26,3 +26,5 @@ pnpm-debug.log*
coverage/* coverage/*
junit.xml junit.xml
/.vs /.vs
.prettierrc

View file

@ -1,23 +1,18 @@
<template> <template>
<div <div class="textbox-question" :class="(errors && errors.length) || hasError ? 'has-error' : ''">
class="textbox-question"
:class="(errors && errors.length) || hasError ? 'has-error' : ''"
>
<label <label
v-if="displayQuestionText" v-if="displayQuestionText"
:for="inputId" :for="inputId"
:aria-label="questionText" :aria-label="questionText"
class="form-label" class="form-label"
:class="[questionAlignment === 'center' ? 'text-center w-100 mb-5' : '']" :class="[questionAlignment === 'center' ? 'text-center w-100 mb-5' : '']"
v-html="labelText" v-html="labelText"></label>
></label>
<div <div
class="input-wrapper" class="input-wrapper"
:class="[ :class="[
includeSearchIcon ? 'has-search-icon' : '', includeSearchIcon ? 'has-search-icon' : '',
includeSelectIcon ? 'has-select-icon' : '', includeSelectIcon ? 'has-select-icon' : '',
]" ]">
>
<input <input
class="form-control" class="form-control"
v-model.trim.lazy="value" v-model.trim.lazy="value"
@ -47,20 +42,14 @@
:data-bs-toggle="includeSelectIcon ? 'modal' : ''" :data-bs-toggle="includeSelectIcon ? 'modal' : ''"
:data-bs-target="'#' + this.cmsWidgetName" :data-bs-target="'#' + this.cmsWidgetName"
@paste="trimOnPaste" @paste="trimOnPaste"
@drop="trimOnPaste" @drop="trimOnPaste" />
/> <button v-if="includeSearchIcon" type="submit" aria-label="Search button" />
<button
v-if="includeSearchIcon"
type="submit"
aria-label="Search button"
/>
<button <button
v-if="includeSelectIcon" v-if="includeSelectIcon"
type="submit" type="submit"
data-bs-toggle="modal" data-bs-toggle="modal"
:data-bs-target="'#' + this.cmsWidgetName" :data-bs-target="'#' + this.cmsWidgetName"
aria-label="Select button" aria-label="Select button" />
/>
</div> </div>
<div v-show="errorMessage" class="row my-1 form-test-error"> <div v-show="errorMessage" class="row my-1 form-test-error">
<span class="d-inline-flex mt-0" role="alert">{{ errorMessage }}</span> <span class="d-inline-flex mt-0" role="alert">{{ errorMessage }}</span>
@ -131,8 +120,11 @@ export default {
initialValue: initialValue, initialValue: initialValue,
}; };
const { errorMessage, handleBlur, handleChange, meta, validate, errors } = const { errorMessage, handleBlur, handleChange, meta, validate, errors } = useField(
useField(props.inputId, props.validationRules, fieldOptions); props.inputId,
props.validationRules,
fieldOptions
);
return { return {
errorMessage, errorMessage,
@ -146,14 +138,15 @@ export default {
methods: { methods: {
trimOnPaste(evt) { trimOnPaste(evt) {
evt.stopPropagation(); evt.stopPropagation();
preventDefault();
var data = null; var data = null;
if (evt.type === "paste") { if (evt.type === "paste") {
data = evt.clipboardData || window.clipboardData; data = evt.clipboardData || window.clipboardData;
} else if (evt.type === "drop") { } else {
evt.preventDefault();
data = evt.dataTransfer; data = evt.dataTransfer;
} }
const value = data.getData("Text")?.trim(); const value = data.getData("Text")?.trim();
this.$emit("update:modelValue", value); this.$emit("update:modelValue", value);

View file

@ -1,5 +1,9 @@
<template> <template>
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }" > <Form
ref="theForm"
v-slot="{ meta }"
@submit="onSubmit"
@invalid-submit="onInvalidSubmit">
<div class="page-container-grouped-styles"> <div class="page-container-grouped-styles">
<div class="fade-on-route-transition position-relative"> <div class="fade-on-route-transition position-relative">
<siteHeader cmsWidgetName="SiteHeaderWidget" /> <siteHeader cmsWidgetName="SiteHeaderWidget" />
@ -9,107 +13,75 @@
<div class="col"> <div class="col">
<div class="select-car-form rounded pb-1"> <div class="select-car-form rounded pb-1">
<textBlock <textBlock
id="coverage-statement-text-block"
cmsWidgetName="verifyingCoverageStatement" cmsWidgetName="verifyingCoverageStatement"
typeStyle="h5" typeStyle="h5"
justifyText="center" justifyText="center"
class="mt-4 mb-4" class="mt-4 mb-4" />
id="coverage-statement-text-block" />
<div> <div>
<p v-html="continueWithSchedulingBodyText" class="mt-0 small" ></p> <p
class="mt-0 small"
v-html="continueWithSchedulingBodyText"></p>
</div> </div>
<textBlock <textBlock
id="coverage-statement-text-block"
cmsWidgetName="whatHappensNextCopy" cmsWidgetName="whatHappensNextCopy"
class="mt-4 mb-2 fw-bold" class="mt-4 mb-2 fw-bold" />
id="coverage-statement-text-block" />
<div> <div>
<p class="small" v-html="bodyText" ref="coverageStatementBodyText"></p> <p
ref="coverageStatementBodyText"
class="small"
v-html="bodyText"></p>
</div> </div>
<steeringText cmsWidgetName="MASteeringText"></steeringText> <steeringText cmsWidgetName="MASteeringText"></steeringText>
</div> </div>
<siteFooter <siteFooter
ref="siteFooter"
class="mt-5" class="mt-5"
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@backClicked="navigateBack" @backClicked="navigateBack"
@forwardClicked="forwardButtonAction" @forwardClicked="forwardButtonAction" />
ref="siteFooter" />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<recalModal ref="RecalModal" cmsWidgetName="RecalModal" /> <recalModal
ref="RecalModal"
cmsWidgetName="RecalModal" />
</Form> </Form>
</template> </template>
<script> <script>
// Import Component // Import Component
import baseFormMixin from '@/mixins/base-form-mixin';
import { Form } from 'vee-validate'; import { Form } from 'vee-validate';
import siteFooter from '@/iss-components/site-footer/site-footer.vue'; import siteFooter from '@/iss-components/site-footer/site-footer';
import siteHeader from '@/iss-components/site-header/site-header.vue'; import siteHeader from '@/iss-components/site-header/site-header';
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue'; import textBlock from '@/digital-components/text-block/text-block';
import textBlock from "@/digital-components/text-block/text-block"; import recalModal from '@/layouts/coverage-statement/recal-modal/recal-modal';
import recalModal from '@/layouts/coverage-statement/recal-modal/recal-modal.vue'; import steeringText from '@/iss-components/steering-text/steering-text';
import steeringText from "@/iss-components/steering-text/steering-text.vue";
// Import Supporting Files // Import Supporting Files
import { fetchCmsContentForPage, setupModalLinks } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage, setupModalLinks } from '@/helpers/cms-content-helper.js';
import { settleAllPromises } from '@/helpers/layout-helper'; import { settleAllPromises } from '@/helpers/layout-helper.js';
import { getDamageString } from '@/helpers/damage-helper.js'; import { getDamageString } from '@/helpers/damage-helper.js';
import { useMainStore } from "@/store"; import { useMainStore } from '@/store/index.js';
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin"; import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin.js';
import baseFormMixin from '@/mixins/base-form-mixin.js';
export default { export default {
name: 'coverage-statement', name: 'coverage-statement',
mixins: [baseFormMixin, vehicleQuestionsMixin],
components: { components: {
siteFooter, siteFooter,
siteHeader, siteHeader,
siteSubHeader, // eslint-disable-next-line vue/no-reserved-component-names
Form, Form,
textBlock, textBlock,
recalModal, recalModal,
steeringText steeringText
}, },
mounted() { mixins: [baseFormMixin, vehicleQuestionsMixin],
setupModalLinks(this);
},
computed: {
bodyText() {
if (useMainStore().damage.isRepair) {
return this.unverifiedNonADASRepairBodyText;
}
else {
let parts = useMainStore().lineItems.glassParts;
// if ADAS, display ADASNextSteps
if (parts != null && parts.filter(part => part.requiresRecalibration).length > 0) {
return this.unverifiedADASNextStepsBodyText;
}
// if non-ADAS, display NonADASNextSteps
else {
return this.unverifiedNonADASNextStepsBodyText;
}
}
},
continueWithSchedulingBodyText() {
return this.getCmsContent("continueWithSchedulingCopy", "BodyText");
},
unverifiedADASNextStepsBodyText() {
return this.getCmsContent("UnverifiedADASNextStepsWidget", "BodyText").replaceAll("{custom:damage}", this.damageText);
},
unverifiedNonADASNextStepsBodyText() {
return this.getCmsContent("UnverifiedNonADASNextStepsWidget", "BodyText").replaceAll("{custom:damage}", this.damageText);
},
unverifiedNonADASRepairBodyText() {
return this.getCmsContent("UnverifiedNonADASRepairWidget", "BodyText");
},
damageText() {
var damageString = getDamageString();
return damageString == "match" ? "" : damageString;
},
},
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
@ -118,15 +90,15 @@ export default {
const promiseResultMap = [ const promiseResultMap = [
{ {
resultKey: 'cmsContent', resultKey: 'cmsContent',
promise: cmsContentPromise, promise: cmsContentPromise
}, }
]; ];
if (useMainStore().isClaimRegistrationRequired){ if (useMainStore().isClaimRegistrationRequired && !useMainStore().policy.noCoverage) {
const registerClaimResponse = await useMainStore().registerClaim(); const registerClaimResponse = await useMainStore().registerClaim();
promiseResultMap.push({ promiseResultMap.push({
resultKey: 'registerClaim', resultKey: 'registerClaim',
promise: registerClaimResponse, promise: registerClaimResponse
}); });
} }
@ -136,6 +108,43 @@ export default {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
}); });
}, },
computed: {
bodyText() {
if (useMainStore().damage.isRepair) {
return this.unverifiedNonADASRepairBodyText;
}
const parts = useMainStore().lineItems.glassParts;
// if ADAS, display ADASNextSteps
if (parts != null && parts.filter((part) =>
part.requiresRecalibration).length > 0) {
return this.unverifiedADASNextStepsBodyText;
}
// if non-ADAS, display NonADASNextSteps
return this.unverifiedNonADASNextStepsBodyText;
},
continueWithSchedulingBodyText() {
return this.getCmsContent('continueWithSchedulingCopy', 'BodyText');
},
unverifiedADASNextStepsBodyText() {
return this.getCmsContent('UnverifiedADASNextStepsWidget', 'BodyText').replaceAll('{custom:damage}', this.damageText);
},
unverifiedNonADASNextStepsBodyText() {
return this.getCmsContent('UnverifiedNonADASNextStepsWidget', 'BodyText').replaceAll('{custom:damage}', this.damageText);
},
unverifiedNonADASRepairBodyText() {
return this.getCmsContent('UnverifiedNonADASRepairWidget', 'BodyText');
},
damageText() {
const damageString = getDamageString();
return damageString === 'match' ? '' : damageString;
}
},
mounted() {
setupModalLinks(this);
},
methods: { methods: {
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
if (useMainStore().vehicle.vin) { if (useMainStore().vehicle.vin) {
@ -149,12 +158,10 @@ export default {
}, },
navigateForward() { navigateForward() {
this.$router.navigate( this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,
this.navigationScenarios.CLICKED_FORWARD, this.$route);
this.$route }
); }
},
},
}; };
</script> </script>

View file

@ -66,7 +66,7 @@ describe('policy-vehicles.vue', () => {
const expectedInput = { const expectedInput = {
year: year, year: year,
vin: vin, vin: vin,
noCompensation: true, noCoverage: true,
deductible: 0, deductible: 0,
repairWaived: false repairWaived: false
} }
@ -130,9 +130,9 @@ describe('policy-vehicles.vue', () => {
{} {}
); );
}); });
}) });
describe('noCompensationForSelectedVehicle computed property', () => { describe('noCoverageForSelectedVehicle computed property', () => {
it('No vehicle match => returns true', async () => { it('No vehicle match => returns true', async () => {
// Arrange // Arrange
const selectedVin = getRandomString(17, 17); const selectedVin = getRandomString(17, 17);
@ -141,13 +141,13 @@ describe('policy-vehicles.vue', () => {
selectedVehicleVin: selectedVin, selectedVehicleVin: selectedVin,
policyVehicles: [ policyVehicles: [
{ {
vin: otherVin, vin: otherVin
},
],
} }
]
};
// Act // Act
const result = policyVehicles.computed.noCompensationForSelectedVehicle.call(testValues); const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues);
// Assert // Assert
expect(result).toBeTruthy(); expect(result).toBeTruthy();
@ -160,14 +160,14 @@ describe('policy-vehicles.vue', () => {
selectedVehicleVin: vin, selectedVehicleVin: vin,
policyVehicles: [ policyVehicles: [
{ {
vin: vin, vin,
coverages: [] coverages: []
},
],
} }
]
};
// Act // Act
const result = policyVehicles.computed.noCompensationForSelectedVehicle.call(testValues); const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues);
// Assert // Assert
expect(result).toBeTruthy(); expect(result).toBeTruthy();
@ -180,23 +180,23 @@ describe('policy-vehicles.vue', () => {
selectedVehicleVin: vin, selectedVehicleVin: vin,
policyVehicles: [ policyVehicles: [
{ {
vin: vin, vin,
coverages: [ coverages: [
{ {
deductible: 0 deductible: 0
} }
] ]
},
],
} }
]
};
// Act // Act
const result = policyVehicles.computed.noCompensationForSelectedVehicle.call(testValues); const result = policyVehicles.computed.noCoverageForSelectedVehicle.call(testValues);
// Assert // Assert
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });
}) });
describe('deductibleForSelectedVehicle computed property', () => { describe('deductibleForSelectedVehicle computed property', () => {

View file

@ -104,7 +104,7 @@ export default {
}) ?? []; }) ?? [];
return mappedData; return mappedData;
}, },
noCompensationForSelectedVehicle() { noCoverageForSelectedVehicle() {
const vehicle = this.policyVehicles.find((policyVehicle) => const vehicle = this.policyVehicles.find((policyVehicle) =>
policyVehicle.vin === this.selectedVehicleVin); policyVehicle.vin === this.selectedVehicleVin);
return (vehicle?.coverages?.length ?? 0) === 0; return (vehicle?.coverages?.length ?? 0) === 0;
@ -174,7 +174,7 @@ export default {
this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, { this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, {
vin: this.selectedVehicleVin, vin: this.selectedVehicleVin,
noCompensation: this.noCompensationForSelectedVehicle, noCoverage: this.noCoverageForSelectedVehicle,
deductible: this.deductibleForSelectedVehicle, deductible: this.deductibleForSelectedVehicle,
repairWaived: this.repairWaivedForSelectedVehicle repairWaived: this.repairWaivedForSelectedVehicle
}); });

View file

@ -58,7 +58,7 @@ const getDefaultState = () =>
damageState: null, damageState: null,
damageCity: null, damageCity: null,
isDamageGlassOnly: null, isDamageGlassOnly: null,
noCompensation: null, noCoverage: null,
deductible: { deductible: {
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,
@ -394,6 +394,7 @@ export const useMainStore = defineStore({
registerClaim() { registerClaim() {
// TODO: replace place holder correlationId with the real thing // TODO: replace place holder correlationId with the real thing
const placeHolderCorrelationId = '00000000-0000-0000-0000-000000000000'; const placeHolderCorrelationId = '00000000-0000-0000-0000-000000000000';
const nonNumberCharRegex = /[^0-9]/g;
globalMethods.callHttpClient({ globalMethods.callHttpClient({
method: endpoints.RegisterClaim.method, method: endpoints.RegisterClaim.method,
endpoint: endpoints.RegisterClaim.url, endpoint: endpoints.RegisterClaim.url,
@ -413,9 +414,13 @@ export const useMainStore = defineStore({
country: 'US' // TODO set from store country: 'US' // TODO set from store
}, },
homePhone: { homePhone: {
number: this.order.customer.phoneNumber number: this.order.customer.phoneNumber?.replaceAll(nonNumberCharRegex, '') ?? ''
} }
}, },
driver: {
firstName: this.order.customer.firstName,
lastName: this.order.customer.lastName
},
caller: { caller: {
homePhone: {} homePhone: {}
}, },
@ -437,18 +442,20 @@ export const useMainStore = defineStore({
make: this.order.vehicle.make, make: this.order.vehicle.make,
model: this.order.vehicle.model, model: this.order.vehicle.model,
vin: this.order.vehicle.vin vin: this.order.vehicle.vin
}
}, },
damageDescription: this.order.policy.damageCause damageDescription: this.order.policy.damageCause
} }
}
}).then((response) => { }).then((response) => {
const registerClaimFailed = response.data.isError; const registerClaimFailed = response.data.isError;
this.order.payment.insuranceCoverage.isVerified = !registerClaimFailed; this.order.payment.insuranceCoverage.isVerified = !registerClaimFailed;
this.order.payment.insuranceCoverage.coverageStatus = registerClaimFailed if (registerClaimFailed) {
? coverageStatuses.PENDING this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
: this.policy.noCompensation } else if (this.policy.noCoverage) {
? coverageStatuses.NO_COMP this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.NO_COMP;
: coverageStatuses.VERIFIED; } else {
this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED;
}
}, (error) => { }, (error) => {
this.order.payment.insuranceCoverage.isVerified = false; this.order.payment.insuranceCoverage.isVerified = false;
this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING; this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
@ -892,7 +899,7 @@ export const useMainStore = defineStore({
this.order.vehicle.imageColor = vehicle.imageVifColor; this.order.vehicle.imageColor = vehicle.imageVifColor;
// These could be undefined // These could be undefined
this.order.policy.noCompensation = vehicle.noCoverage; this.order.policy.noCoverage = vehicle.noCoverage;
this.order.policy.deductible.replace = vehicle.deductible; this.order.policy.deductible.replace = vehicle.deductible;
this.order.policy.deductible.repair = vehicle?.repairWaived ?? false ? 0 : vehicle.deductible; this.order.policy.deductible.repair = vehicle?.repairWaived ?? false ? 0 : vehicle.deductible;

View file

@ -1,32 +1,30 @@
import { useMainStore } from '@/store'; import { useMainStore } from '@/store/index.js';
import { createApp } from 'vue'; import { setActivePinia, createPinia } from 'pinia';
import { setActivePinia, createPinia } from "pinia"; import { getRandomString,
import globalMethods from "@/global-methods"; getRandomGuid,
import App from '@/App'; getRandomInt,
import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation'; getRandomBoolean } from '@/helpers/data-generation.js';
import { coverageStatuses } from "@/constants/coverage-statuses.js"; import { coverageStatuses } from '@/constants/coverage-statuses.js';
import globalMethods from '@/global-methods.js';
describe("Store", () => { describe('Store', () => {
let store; let store;
const vueApp = createApp(App);
beforeEach(() => { beforeEach(() => {
const pinia = createPinia(); const pinia = createPinia();
setActivePinia(pinia); setActivePinia(pinia);
vueApp.use(pinia);
store = useMainStore(); store = useMainStore();
store.applicationUser.eventBus = []; store.applicationUser.eventBus = [];
jest.resetAllMocks(); jest.resetAllMocks();
}); });
it("Should Store Vehicle Year", () => { it('Should Store Vehicle Year', () => {
let testYear = "2001"; const testYear = '2001';
store.updateVehicleYear(testYear); store.updateVehicleYear(testYear);
expect(store.order.vehicle.year).toEqual(testYear); expect(store.order.vehicle.year).toEqual(testYear);
}); });
it("Should add events to the bus", () => { it('Should add events to the bus', () => {
// Arrange // Arrange
const category = getRandomString(1, 25); const category = getRandomString(1, 25);
const subCategory = getRandomString(5, 20); const subCategory = getRandomString(5, 20);
@ -34,15 +32,15 @@ describe("Store", () => {
const copy = getRandomString(5, 25); const copy = getRandomString(5, 25);
const headline = getRandomString(5, 25); const headline = getRandomString(5, 25);
const type = getRandomString(5, 15); const type = getRandomString(5, 15);
let event = { const event = {
category: category, category,
subCategory: subCategory, subCategory,
eventValue: { eventValue: {
isDismissible: isDismissible, isDismissible,
messageCopy: copy, messageCopy: copy,
messageHeadline: headline, messageHeadline: headline,
type: type, type
}, }
}; };
// Act // Act
@ -52,7 +50,7 @@ describe("Store", () => {
expect(store.applicationUser.eventBus[0]).toEqual(event); expect(store.applicationUser.eventBus[0]).toEqual(event);
}); });
it("Should remove events from the bus", () => { it('Should remove events from the bus', () => {
// Arrange // Arrange
const category = getRandomString(1, 25); const category = getRandomString(1, 25);
const subCategory = getRandomString(5, 20); const subCategory = getRandomString(5, 20);
@ -60,15 +58,15 @@ describe("Store", () => {
const copy = getRandomString(5, 25); const copy = getRandomString(5, 25);
const headline = getRandomString(5, 25); const headline = getRandomString(5, 25);
const type = getRandomString(5, 15); const type = getRandomString(5, 15);
let event = { const event = {
category: category, category,
subCategory: subCategory, subCategory,
eventValue: { eventValue: {
isDismissible: isDismissible, isDismissible,
messageCopy: copy, messageCopy: copy,
messageHeadline: headline, messageHeadline: headline,
type: type, type
}, }
}; };
store.addEventToBus(event); store.addEventToBus(event);
@ -82,7 +80,7 @@ describe("Store", () => {
expect(store.applicationUser.eventBus.length).toBe(0); expect(store.applicationUser.eventBus.length).toBe(0);
}); });
it("Should return correct event using the getter function eventBusItem", () => { it('Should return correct event using the getter function eventBusItem', () => {
// Arrange // Arrange
const category = getRandomString(1, 25); const category = getRandomString(1, 25);
const subCategory = getRandomString(5, 20); const subCategory = getRandomString(5, 20);
@ -90,27 +88,27 @@ describe("Store", () => {
const copy = getRandomString(5, 25); const copy = getRandomString(5, 25);
const headline = getRandomString(5, 25); const headline = getRandomString(5, 25);
const type = getRandomString(5, 15); const type = getRandomString(5, 15);
let event = { const event = {
category: category, category,
subCategory: subCategory, subCategory,
eventValue: { eventValue: {
isDismissible: isDismissible, isDismissible,
messageCopy: copy, messageCopy: copy,
messageHeadline: headline, messageHeadline: headline,
type: type, type
}, }
}; };
store.addEventToBus(event); store.addEventToBus(event);
// Act // Act
const actual = store.eventBusItem(event.category, event.subCategory) const actual = store.eventBusItem(event.category, event.subCategory);
// Assert // Assert
expect(actual).toEqual(event.eventValue); expect(actual).toEqual(event.eventValue);
}); });
it("UpdateVehicle should merge vehicle with response object", () => { it('UpdateVehicle should merge vehicle with response object', () => {
// Arrange // Arrange
const carId = getRandomString(10, 14); const carId = getRandomString(10, 14);
const category = getRandomString(3, 7); const category = getRandomString(3, 7);
@ -122,28 +120,28 @@ describe("Store", () => {
const imageVifNumber = getRandomInt(10000, 99999).toString(); const imageVifNumber = getRandomInt(10000, 99999).toString();
const imageColor = getRandomString(4, 10); const imageColor = getRandomString(4, 10);
const providedVehicle = { const providedVehicle = {
carId: carId, carId,
category: category, category,
year: year, year,
make: make, make,
model: model, model,
style: style, style,
imageUrl: imageUrl, imageUrl,
imageVifNumber: imageVifNumber, imageVifNumber,
imageVifColor: imageColor imageVifColor: imageColor
}; };
const expectedVehicle = { const expectedVehicle = {
carId: carId, carId,
category: category, category,
year: year, year,
make: make, make,
model: model, model,
style: style, style,
imageUrl: imageUrl, imageUrl,
imageVifNumber: imageVifNumber, imageVifNumber,
imageColor: imageColor imageColor
} };
// Act // Act
store.updateVehicle(providedVehicle); store.updateVehicle(providedVehicle);
@ -152,18 +150,18 @@ describe("Store", () => {
expect(store.order.vehicle).toMatchObject(expectedVehicle); expect(store.order.vehicle).toMatchObject(expectedVehicle);
}); });
it("UpdateVehicle should set policy values appropriately with repair waived", () => { it('UpdateVehicle should set policy values appropriately with repair waived', () => {
// Arrange // Arrange
const noCompensation = getRandomBoolean(); const noCoverage = getRandomBoolean();
const deductible = getRandomInt(1, 500); const deductible = getRandomInt(1, 500);
const vehicle = { const vehicle = {
noCoverage: noCompensation, noCoverage,
deductible: deductible, deductible,
repairWaived: true repairWaived: true
}; };
const expectedPolicy = { const expectedPolicy = {
noCompensation: noCompensation, noCoverage,
deductible: { deductible: {
replace: deductible, replace: deductible,
repair: 0 repair: 0
@ -177,18 +175,18 @@ describe("Store", () => {
expect(store.order.policy).toMatchObject(expectedPolicy); expect(store.order.policy).toMatchObject(expectedPolicy);
}); });
it("UpdateVehicle should set policy values appropriately with repair not waived", () => { it('UpdateVehicle should set policy values appropriately with repair not waived', () => {
// Arrange // Arrange
const noCompensation = getRandomBoolean(); const noCoverage = getRandomBoolean();
const deductible = getRandomInt(1, 500); const deductible = getRandomInt(1, 500);
const vehicle = { const vehicle = {
noCoverage: noCompensation, noCoverage,
deductible: deductible, deductible,
repairWaived: false repairWaived: false
}; };
const expectedPolicy = { const expectedPolicy = {
noCompensation: noCompensation, noCoverage,
deductible: { deductible: {
replace: deductible, replace: deductible,
repair: deductible repair: deductible
@ -203,7 +201,7 @@ describe("Store", () => {
}); });
// TODO update test to work also checking store values // TODO update test to work also checking store values
it("setVehicle should call globalMethods.callHttpClient", () => { it('setVehicle should call globalMethods.callHttpClient', () => {
// Arrange // Arrange
const carId = getRandomString(10, 14); const carId = getRandomString(10, 14);
const category = getRandomString(3, 7); const category = getRandomString(3, 7);
@ -216,14 +214,14 @@ describe("Store", () => {
const imageColor = getRandomString(4, 10); const imageColor = getRandomString(4, 10);
const response = { const response = {
data: { data: {
carId: carId, carId,
category: category, category,
year: year, year,
make: make, make,
model: model, model,
style: style, style,
imageUrl: imageUrl, imageUrl,
imageVifNumber: imageVifNumber, imageVifNumber,
imageVifColor: imageColor imageVifColor: imageColor
} }
}; };
@ -238,14 +236,14 @@ describe("Store", () => {
expect(returned).resolves.toMatchObject(response); expect(returned).resolves.toMatchObject(response);
}); });
it("saveVehicleDamage with windshield repair should update damage with number of chips not null", () => { it('saveVehicleDamage with windshield repair should update damage with number of chips not null', () => {
// Arrange // Arrange
const glassName = getRandomString(4, 10); const glassName = getRandomString(4, 10);
const glassLocation = getRandomString(5, 15); const glassLocation = getRandomString(5, 15);
const isWindshieldRepair = true; const isWindshieldRepair = true;
const selectedGlassToReplace = [{ const selectedGlassToReplace = [{
glassName: glassName, glassName,
glassLocation: glassLocation glassLocation
}]; }];
const chipCount = getRandomInt(0, 3); const chipCount = getRandomInt(0, 3);
@ -258,14 +256,14 @@ describe("Store", () => {
expect(store.order.damage.numberOfChips).toEqual(chipCount); expect(store.order.damage.numberOfChips).toEqual(chipCount);
}); });
it("saveVehicleDamage without windshield repair should update damage with number of chips null", () => { it('saveVehicleDamage without windshield repair should update damage with number of chips null', () => {
// Arrange // Arrange
const glassName = getRandomString(4, 10); const glassName = getRandomString(4, 10);
const glassLocation = getRandomString(5, 15); const glassLocation = getRandomString(5, 15);
const isWindshieldRepair = false; const isWindshieldRepair = false;
const selectedGlassToReplace = [{ const selectedGlassToReplace = [{
glassName: glassName, glassName,
glassLocation: glassLocation glassLocation
}]; }];
const chipCount = getRandomInt(0, 3); const chipCount = getRandomInt(0, 3);
@ -280,7 +278,7 @@ describe("Store", () => {
expect(store.order.damage.numberOfChips).toEqual(expectedChipCount); expect(store.order.damage.numberOfChips).toEqual(expectedChipCount);
}); });
it("should return registration data if available", () => { it('should return registration data if available', () => {
// Arrange // Arrange
const streetAddress = getRandomString(5, 15); const streetAddress = getRandomString(5, 15);
const city = getRandomString(5, 15); const city = getRandomString(5, 15);
@ -290,23 +288,23 @@ describe("Store", () => {
const lastName = getRandomString(5, 20); const lastName = getRandomString(5, 20);
const expected = { const expected = {
addressQuestions: { addressQuestions: {
streetAddress: streetAddress, streetAddress,
city: city, city,
state: state, state,
zipCode: zipCode, zipCode
}, },
firstName: firstName, firstName,
lastName: lastName, lastName
} };
store.order.vehicle.registration = { store.order.vehicle.registration = {
licensePlate: null, licensePlate: null,
address: streetAddress, address: streetAddress,
city: city, city,
state: state, state,
zipCode: zipCode, zipCode,
firstName: firstName, firstName,
lastName: lastName, lastName
}; };
// Act // Act
@ -316,7 +314,7 @@ describe("Store", () => {
expect(actual).toEqual(expected); expect(actual).toEqual(expected);
}); });
it("should return customer data if registration data unavailable", () => { it('should return customer data if registration data unavailable', () => {
// Arrange // Arrange
const address = getRandomString(1, 25); const address = getRandomString(1, 25);
const city = getRandomString(5, 20); const city = getRandomString(5, 20);
@ -327,25 +325,25 @@ describe("Store", () => {
const expected = { const expected = {
addressQuestions: { addressQuestions: {
streetAddress: address, streetAddress: address,
city: city, city,
state: state, state,
zipCode: zipCode, zipCode
}, },
firstName: firstName, firstName,
lastName: lastName, lastName
} };
store.order.vehicle.registration.address = null; store.order.vehicle.registration.address = null;
store.order.customer = { store.order.customer = {
address: { address: {
streetAddress: address, streetAddress: address,
city: city, city,
state: state, state,
zipCode: zipCode zipCode
}, },
firstName: firstName, firstName,
lastName: lastName lastName
}; };
// Act // Act
@ -355,8 +353,8 @@ describe("Store", () => {
expect(actual).toMatchObject(expected); expect(actual).toMatchObject(expected);
}); });
describe("registerClaim method", () => { describe('registerClaim method', () => {
it("successful response with no coverage => isVerified true and coverage status no comp", async () => { it('successful response with no coverage => isVerified true and coverage status no comp', async () => {
// Arrange // Arrange
const response = { const response = {
data: { data: {
@ -369,7 +367,7 @@ describe("Store", () => {
deductible: 0 deductible: 0
} }
}; };
store.policy.noCompensation = true; store.policy.noCoverage = true;
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response)); globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
@ -382,7 +380,7 @@ describe("Store", () => {
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.NO_COMP); expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.NO_COMP);
}); });
it("successful response with coverage => isVerified true and coverage status verified", async () => { it('successful response with coverage => isVerified true and coverage status verified', async () => {
// Arrange // Arrange
const response = { const response = {
data: { data: {
@ -395,7 +393,7 @@ describe("Store", () => {
deductible: 0 deductible: 0
} }
}; };
store.policy.noCompensation = false; store.policy.noCoverage = false;
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response)); globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
@ -406,9 +404,9 @@ describe("Store", () => {
expect(globalMethods.callHttpClient).toHaveBeenCalled(); expect(globalMethods.callHttpClient).toHaveBeenCalled();
expect(store.payment.insuranceCoverage.isVerified).toBe(true); expect(store.payment.insuranceCoverage.isVerified).toBe(true);
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.VERIFIED); expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.VERIFIED);
}) });
it("Call to client returns exception, resulting in object with error property being returned", async () => { it('Call to client returns exception, resulting in object with error property being returned', async () => {
// Arrange // Arrange
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject()); globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject());