Renamed method

This commit is contained in:
Mark Harris 2022-05-02 09:14:06 -04:00
parent 9401dabaa3
commit de011ae24a
23 changed files with 45 additions and 45 deletions

View file

@ -7,7 +7,7 @@ export function getDamageString() {
} }
export async function isGlassAvailableForCarId(carId){ export async function isGlassAvailableForCarId(carId){
const newGlassOptions = await baseMixin.methods.dispatchNonBlockingStoreAction( const newGlassOptions = await baseMixin.methods.dispatchStoreAction(
storeActions.GET_DAMAGE_OPTIONS, storeActions.GET_DAMAGE_OPTIONS,
{ carId: carId } { carId: carId }
); );

View file

@ -22,7 +22,7 @@ jest.mock("@/store", () => ({
// windshieldOptions: {availableReplacementOptions: ["windshield"]} // windshieldOptions: {availableReplacementOptions: ["windshield"]}
// } // }
// } // }
// baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn().mockImplementation(()=> { // baseMixin.methods.dispatchStoreAction = jest.fn().mockImplementation(()=> {
// return updatedOptions; // return updatedOptions;
// }); // });
// const misMatch = await isGlassAvailableForCarId(); // const misMatch = await isGlassAvailableForCarId();

View file

@ -18,7 +18,7 @@ export async function loadOrderIfPresent() {
// Reset state if cookie says to. // Reset state if cookie says to.
if (funnelCookie.ShouldResetState) { if (funnelCookie.ShouldResetState) {
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.RESET_STATE); baseMixin.methods.dispatchStoreAction(storeActions.RESET_STATE);
deleteFunnelCookie(); deleteFunnelCookie();
return null; return null;
} }
@ -34,10 +34,10 @@ export async function loadOrderIfPresent() {
update the cookie. update the cookie.
*/ */
export async function saveOrder() { export async function saveOrder() {
const savedOrderInfo = await baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.SAVE_ORDER); const savedOrderInfo = await baseMixin.methods.dispatchStoreAction(storeActions.SAVE_ORDER);
// Save the referral information back from the store. // Save the referral information back from the store.
await baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.SET_REFERRAL_INFORMATION, { await baseMixin.methods.dispatchStoreAction(storeActions.SET_REFERRAL_INFORMATION, {
referralNumber: savedOrderInfo.data.referralNumber, referralNumber: savedOrderInfo.data.referralNumber,
referralCorrelationId: savedOrderInfo.data.referralCorrelationId, referralCorrelationId: savedOrderInfo.data.referralCorrelationId,
referralDate: savedOrderInfo.data.referralDate, referralDate: savedOrderInfo.data.referralDate,
@ -56,7 +56,7 @@ export async function saveOrder() {
and returns the response. and returns the response.
*/ */
async function loadOrder(referralNumber, referralDate, referralCorrelationId, accountNumber) { async function loadOrder(referralNumber, referralDate, referralCorrelationId, accountNumber) {
const response = await baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOAD_ORDER, const response = await baseMixin.methods.dispatchStoreAction(storeActions.LOAD_ORDER,
{ {
referralNumber: referralNumber.toString(), referralNumber: referralNumber.toString(),
referralDate: referralDate, referralDate: referralDate,

View file

@ -48,7 +48,7 @@ describe("loadOrderIfPresent", () => {
// Assert // Assert
expect(cookieHelper.getFunnelCookie).toHaveBeenCalled(); expect(cookieHelper.getFunnelCookie).toHaveBeenCalled();
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).toHaveBeenCalledWith(storeActions.RESET_STATE); expect(mocks.baseMixin.methods.dispatchStoreAction).toHaveBeenCalledWith(storeActions.RESET_STATE);
}); });
test("Funnel cookie is null => store is unchanged", () => { test("Funnel cookie is null => store is unchanged", () => {
@ -68,7 +68,7 @@ describe("loadOrderIfPresent", () => {
// Assert // Assert
expect(cookieHelper.getFunnelCookie).toHaveBeenCalled(); expect(cookieHelper.getFunnelCookie).toHaveBeenCalled();
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).not.toHaveBeenCalledWith(storeActions.RESET_STATE); expect(mocks.baseMixin.methods.dispatchStoreAction).not.toHaveBeenCalledWith(storeActions.RESET_STATE);
}); });
test("Funnel cookie valid, should call loadOrder", async () => { test("Funnel cookie valid, should call loadOrder", async () => {
@ -90,7 +90,7 @@ describe("loadOrderIfPresent", () => {
// Assert // Assert
expect(cookieHelper.getFunnelCookie).toHaveBeenCalled(); expect(cookieHelper.getFunnelCookie).toHaveBeenCalled();
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).not.toHaveBeenCalledWith(storeActions.LOAD_ORDER); expect(mocks.baseMixin.methods.dispatchStoreAction).not.toHaveBeenCalledWith(storeActions.LOAD_ORDER);
expect(result.ReferralNumber).toBe(123456); expect(result.ReferralNumber).toBe(123456);
expect(result.vehicle.year).toBe(2010); expect(result.vehicle.year).toBe(2010);
}); });
@ -127,8 +127,8 @@ describe("saveOrder", () => {
await saveOrder(); await saveOrder();
// Assert // Assert
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).toHaveBeenCalledWith(storeActions.SAVE_ORDER); expect(mocks.baseMixin.methods.dispatchStoreAction).toHaveBeenCalledWith(storeActions.SAVE_ORDER);
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).toHaveBeenCalledWith(storeActions.SET_REFERRAL_INFORMATION, { expect(mocks.baseMixin.methods.dispatchStoreAction).toHaveBeenCalledWith(storeActions.SET_REFERRAL_INFORMATION, {
referralNumber: mockReferralNumber, referralNumber: mockReferralNumber,
referralDate: mockReferralDate, referralDate: mockReferralDate,
referralCorrelationId: mockCorrelationId referralCorrelationId: mockCorrelationId

View file

@ -15,16 +15,16 @@ export function getMountOptions(mockData) {
// Define our mocks to attached to the 'global' object for Vue/Jest. // Define our mocks to attached to the 'global' object for Vue/Jest.
const mocks = {}; const mocks = {};
//this is mocking if you use the mixin directly(baseMixin.methods.dispatchNonBlockingStoreAction) vs this.dispatchNonBlockingStoreAction //this is mocking if you use the mixin directly(baseMixin.methods.dispatchStoreAction) vs this.dispatchStoreAction
setupBaseMixinDispatchNonBlockingStoreAction(mockData); setupBaseMixinDispatchStoreAction(mockData);
mocks.pushEventToGA = jest.fn(); mocks.pushEventToGA = jest.fn();
mocks.pushPageViewToGA = jest.fn(); mocks.pushPageViewToGA = jest.fn();
mocks.logEvent = jest.fn(); mocks.logEvent = jest.fn();
mocks.pushExperimentsToDataLayer = jest.fn(); mocks.pushExperimentsToDataLayer = jest.fn();
mocks.dispatchNonBlockingStoreAction = jest.fn(); mocks.dispatchStoreAction = jest.fn();
mocks.dispatchNonBlockingStoreAction.mockImplementation((actionName) => { mocks.dispatchStoreAction.mockImplementation((actionName) => {
let actionFilterResult = mockData.actionList.filter( let actionFilterResult = mockData.actionList.filter(
(x) => x.actionName == actionName (x) => x.actionName == actionName
); );
@ -63,7 +63,7 @@ export function getMountOptions(mockData) {
} }
export function setupMocksForJsFiles(mockData = {}) { export function setupMocksForJsFiles(mockData = {}) {
setupBaseMixinDispatchNonBlockingStoreAction(mockData); setupBaseMixinDispatchStoreAction(mockData);
return { baseMixin }; return { baseMixin };
} }
@ -103,10 +103,10 @@ export function setupCookies({ funnelCookieValue = "", includeHeritageCookie = t
} }
// Private methods // Private methods
function setupBaseMixinDispatchNonBlockingStoreAction(mockData) { function setupBaseMixinDispatchStoreAction(mockData) {
if (mockData.actionList !== undefined) { if (mockData.actionList !== undefined) {
baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn(); baseMixin.methods.dispatchStoreAction = jest.fn();
baseMixin.methods.dispatchNonBlockingStoreAction.mockImplementation((actionName) => { baseMixin.methods.dispatchStoreAction.mockImplementation((actionName) => {
let actionFilterResult = mockData.actionList.filter( let actionFilterResult = mockData.actionList.filter(
(x) => x.actionName == actionName (x) => x.actionName == actionName
); );

View file

@ -95,7 +95,7 @@ export default {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage('vehicle-damage'); const cmsContentPromise = fetchCmsContentForPage('vehicle-damage');
const damageOptionsPromise = const damageOptionsPromise =
baseMixin.methods.dispatchNonBlockingStoreAction( baseMixin.methods.dispatchStoreAction(
storeActions.GET_DAMAGE_OPTIONS, storeActions.GET_DAMAGE_OPTIONS,
{ carId: store.getters.vehicle.carId } { carId: store.getters.vehicle.carId }
); );

View file

@ -115,7 +115,7 @@ function setupMocks({
}, },
}) { }) {
//Mock api responses //Mock api responses
baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn(); baseMixin.methods.dispatchStoreAction = jest.fn();
const apiResponses = { const apiResponses = {
cmsContent: { cmsContent: {
FunnelSubHeaderWidget: pageHeaderWidgetHeaderText, FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,

View file

@ -207,7 +207,7 @@ export default {
this.updateCustomerInfo(vinLookup.data.vin, vinLookup.data.vehicle, zipValidation.data.state); this.updateCustomerInfo(vinLookup.data.vin, vinLookup.data.vehicle, zipValidation.data.state);
const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction( const partsData = await baseMixin.methods.dispatchStoreAction(
this.storeActions.GET_PARTS_OR_QUESTIONS, this.storeActions.GET_PARTS_OR_QUESTIONS,
{ {
carId: vinLookup.data.vehicle.carId, carId: vinLookup.data.vehicle.carId,
@ -229,13 +229,13 @@ export default {
} }
}, },
validateZip(zip) { validateZip(zip) {
return baseMixin.methods.dispatchNonBlockingStoreAction( return baseMixin.methods.dispatchStoreAction(
storeActions.VALIDATE_ZIP, storeActions.VALIDATE_ZIP,
{ zip } { zip }
); );
}, },
lookupVin(plate, state) { lookupVin(plate, state) {
return baseMixin.methods.dispatchNonBlockingStoreAction( return baseMixin.methods.dispatchStoreAction(
storeActions.LOOKUP_VIN_BY_PLATE, storeActions.LOOKUP_VIN_BY_PLATE,
{ licensePlate: plate, licenseState: state } { licensePlate: plate, licenseState: state }
); );

View file

@ -749,7 +749,7 @@ function setupMocks({
}, },
}) { }) {
//Mock api responses //Mock api responses
baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn(); baseMixin.methods.dispatchStoreAction = jest.fn();
const apiResponses = { const apiResponses = {
cmsContent: { cmsContent: {
FunnelSubHeaderWidget: pageHeaderWidgetHeaderText, FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,

View file

@ -93,7 +93,7 @@ export default {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
const damageOptionsPromise = const damageOptionsPromise =
baseMixin.methods.dispatchNonBlockingStoreAction( baseMixin.methods.dispatchStoreAction(
storeActions.GET_DAMAGE_OPTIONS, storeActions.GET_DAMAGE_OPTIONS,
{ carId: store.getters.vehicle.carId } { carId: store.getters.vehicle.carId }
); );
@ -280,7 +280,7 @@ export default {
store.commit(this.storeMutations.UPDATE_GLASS_TO_REPLACE, this.selectedGlassToReplace()); store.commit(this.storeMutations.UPDATE_GLASS_TO_REPLACE, this.selectedGlassToReplace());
const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction(this.storeActions.GET_PARTS_OR_QUESTIONS, const partsData = await baseMixin.methods.dispatchStoreAction(this.storeActions.GET_PARTS_OR_QUESTIONS,
{ carId: store.getters.vehicle.carId, glassArray: this.selectedGlassToReplace()}, false); { carId: store.getters.vehicle.carId, glassArray: this.selectedGlassToReplace()}, false);
this.navigateForward(partsData); this.navigateForward(partsData);

View file

@ -50,7 +50,7 @@ export default {
}, },
methods: { methods: {
loadInitialData() { loadInitialData() {
return baseMixin.methods.dispatchNonBlockingStoreAction( return baseMixin.methods.dispatchStoreAction(
storeActions.GET_VEHICLE_MAKES, storeActions.GET_VEHICLE_MAKES,
{ year: store.getters.vehicle.year } { year: store.getters.vehicle.year }
); );

View file

@ -50,7 +50,7 @@ export default {
}, },
methods: { methods: {
loadInitialData() { loadInitialData() {
return baseMixin.methods.dispatchNonBlockingStoreAction( return baseMixin.methods.dispatchStoreAction(
storeActions.GET_VEHICLE_MODELS, storeActions.GET_VEHICLE_MODELS,
{ year: store.getters.vehicle.year, make: store.getters.vehicle.make } { year: store.getters.vehicle.year, make: store.getters.vehicle.make }
); );

View file

@ -50,7 +50,7 @@ export default {
}, },
methods: { methods: {
loadInitialData() { loadInitialData() {
return baseMixin.methods.dispatchNonBlockingStoreAction( return baseMixin.methods.dispatchStoreAction(
storeActions.GET_VEHICLE_STYLES, storeActions.GET_VEHICLE_STYLES,
{ {
year: store.getters.vehicle.year, year: store.getters.vehicle.year,

View file

@ -87,7 +87,7 @@ describe("vehicle-style.vue", () => {
}); });
describe("vehicle-style.vue", () => { describe("vehicle-style.vue", () => {
test("selectVehicle triggers a dispatchNonBlockingStoreAction commit", async (done) => { test("selectVehicle triggers a dispatchStoreAction commit", async (done) => {
//Arrange //Arrange
const { wrapper, apiPromise } = setupMocks({ const { wrapper, apiPromise } = setupMocks({
pageHeaderWidgetHeaderText: "Select a style to get started", pageHeaderWidgetHeaderText: "Select a style to get started",
@ -119,7 +119,7 @@ describe("vehicle-style.vue", () => {
//Assert //Assert
apiPromise.finally(() => { apiPromise.finally(() => {
expect(wrapper.vm.dispatchNonBlockingStoreAction).toHaveBeenCalled(); expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalled();
done(); done();
}); });
}); });

View file

@ -76,7 +76,7 @@ export default {
); );
}, },
setVehicle() { setVehicle() {
return this.dispatchNonBlockingStoreAction( return this.dispatchStoreAction(
this.storeActions.SET_VEHICLE, this.storeActions.SET_VEHICLE,
{ {
year: this.$store.getters.vehicle.year, year: this.$store.getters.vehicle.year,

View file

@ -44,7 +44,7 @@ export default {
const yearQuestionInitialDataPromise = yearQuestion.methods.loadInitialData(); const yearQuestionInitialDataPromise = yearQuestion.methods.loadInitialData();
// Log experiment exposure // Log experiment exposure
const logExperimentExposurePromise = baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOG_EXPERIMENT_EXPOSURE, const logExperimentExposurePromise = baseMixin.methods.dispatchStoreAction(storeActions.LOG_EXPERIMENT_EXPOSURE,
{ {
userId: getDeviceIdValue(), userId: getDeviceIdValue(),
sessionKey: getSessionKeyValue(), sessionKey: getSessionKeyValue(),

View file

@ -48,7 +48,7 @@ export default {
}, },
methods: { methods: {
loadInitialData() { loadInitialData() {
return baseMixin.methods.dispatchNonBlockingStoreAction( return baseMixin.methods.dispatchStoreAction(
storeActions.GET_VEHICLE_YEARS, storeActions.GET_VEHICLE_YEARS,
{} {}
); );

View file

@ -202,7 +202,7 @@ export default {
} }
const carInfo = this.vinDoesNotMatchCarId ? vinLookup.data : store.getters.vehicle; const carInfo = this.vinDoesNotMatchCarId ? vinLookup.data : store.getters.vehicle;
this.updateStore(carInfo) this.updateStore(carInfo)
const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction( const partsData = await baseMixin.methods.dispatchStoreAction(
this.storeActions.GET_PARTS_OR_QUESTIONS, this.storeActions.GET_PARTS_OR_QUESTIONS,
{ {
carId: store.getters.vehicle.carId, carId: store.getters.vehicle.carId,
@ -226,13 +226,13 @@ export default {
} }
}, },
validateZip(zip) { validateZip(zip) {
return baseMixin.methods.dispatchNonBlockingStoreAction( return baseMixin.methods.dispatchStoreAction(
storeActions.VALIDATE_ZIP, storeActions.VALIDATE_ZIP,
{ zip } { zip }
); );
}, },
lookupVin(vin) { lookupVin(vin) {
return baseMixin.methods.dispatchNonBlockingStoreAction( return baseMixin.methods.dispatchStoreAction(
storeActions.LOOKUP_VEHICLE_BY_VIN, storeActions.LOOKUP_VEHICLE_BY_VIN,
{ vin } { vin }
); );

View file

@ -28,7 +28,7 @@ export default {
payload.customEvent = { category: category, action: action, label: label, value: value }; payload.customEvent = { category: category, action: action, label: label, value: value };
} }
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOG_ACTIVITY, payload, false); baseMixin.methods.dispatchStoreAction(storeActions.LOG_ACTIVITY, payload, false);
}, },
pushEventToGA(category, action, label, pushToLogApp = false) { pushEventToGA(category, action, label, pushToLogApp = false) {

View file

@ -16,7 +16,7 @@ describe("analyticsMixin.js", () => {
analyticsMixin.methods.logEvent(type, payload); analyticsMixin.methods.logEvent(type, payload);
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).toBeCalled(); expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled();
}); });
test("pushEventToGA, should call logEvent too", () => { test("pushEventToGA, should call logEvent too", () => {
@ -32,7 +32,7 @@ describe("analyticsMixin.js", () => {
analyticsMixin.methods.pushEventToGA('category', 'action', 'label', true); analyticsMixin.methods.pushEventToGA('category', 'action', 'label', true);
// Assert // Assert
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).toBeCalled(); expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled();
}); });

View file

@ -18,7 +18,7 @@ export default {
getCmsContent(widgetName, fieldName) { getCmsContent(widgetName, fieldName) {
return this.$root.cmsContentByWidget?.[widgetName]?.[fieldName] ? this.$root.cmsContentByWidget[widgetName][fieldName] : ''; return this.$root.cmsContentByWidget?.[widgetName]?.[fieldName] ? this.$root.cmsContentByWidget[widgetName][fieldName] : '';
}, },
dispatchNonBlockingStoreAction(type, payload, encodePayload = true) { dispatchStoreAction(type, payload, encodePayload = true) {
// Encode the payload if required // Encode the payload if required
if (encodePayload) { if (encodePayload) {
encodeUriData(payload); encodeUriData(payload);

View file

@ -11,7 +11,7 @@ describe("baseMixin.js", () => {
const type = ""; const type = "";
const payload = {}; const payload = {};
mixIn.methods.dispatchNonBlockingStoreAction(type, payload); mixIn.methods.dispatchStoreAction(type, payload);
expect(store.dispatch).toBeCalledWith(type, payload); expect(store.dispatch).toBeCalledWith(type, payload);
}); });
@ -21,7 +21,7 @@ describe("baseMixin.js", () => {
const type = ""; const type = "";
const payload = { make: "Alfa Romeo/Chrysler" }; const payload = { make: "Alfa Romeo/Chrysler" };
mixIn.methods.dispatchNonBlockingStoreAction(type, payload, true); mixIn.methods.dispatchStoreAction(type, payload, true);
expect(store.dispatch).toBeCalledWith(type, payload); expect(store.dispatch).toBeCalledWith(type, payload);
}); });

View file

@ -126,7 +126,7 @@ const router = createRouter({
router.afterEach(async (to, from) => { router.afterEach(async (to, from) => {
// Push page view to GA // Push page view to GA
analyticsMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]); analyticsMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]);
const assignedExperiments = await baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.GET_EXPERIMENTS_BY_USER_FOR_GA, { userId: getDeviceIdValue() }); const assignedExperiments = await baseMixin.methods.dispatchStoreAction(storeActions.GET_EXPERIMENTS_BY_USER_FOR_GA, { userId: getDeviceIdValue() });
analyticsMixin.methods.pushExperimentsToDataLayer(assignedExperiments); analyticsMixin.methods.pushExperimentsToDataLayer(assignedExperiments);
}); });