diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 7b57187c2..2c249750d 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -35,12 +35,10 @@ const storeMutations = { UPDATE_SERVICE_ZIP: "updateServiceZip", UPDATE_SERVICE_LOCATION: "updateServiceLocation", UPDATE_SERVICE_LOCATION_TECH_NOTES: "updateServiceLocationTechNotes", - UPDATE_TECH_NOTES: "updateTechNotes", UPDATE_SCHEDULE: "updateSchedule", - UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress", - // CUSTOMER MUTATIONS + UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress", UPDATE_CUSTOMER_DETAILS: "updateCustomerDetails", // ORDER MUTATIONS diff --git a/src/layouts/customer-details/customer-details.vue b/src/layouts/customer-details/customer-details.vue index be533117f..e91317ca9 100644 --- a/src/layouts/customer-details/customer-details.vue +++ b/src/layouts/customer-details/customer-details.vue @@ -32,7 +32,7 @@ + v-model="isSmsOptIn" /> { lastName: null, emailAddress: null, phoneNumber: null, - isSmsOptin: null, + isSmsOptIn: null, }, damage: { isRepair: null, @@ -291,7 +291,7 @@ export const mutations = { state.order.customer.lastName = customerDetails.lastName; state.order.customer.emailAddress = customerDetails.emailAddress; state.order.customer.phoneNumber = customerDetails.phoneNumber; - state.order.customer.isSmsOptin = customerDetails.isSmsOptin; + state.order.customer.isSmsOptIn = customerDetails.isSmsOptIn; } }, @@ -493,7 +493,7 @@ export const mutations = { state.order.customer.firstName = sessionInformation.order.customer.firstName; state.order.customer.lastName = sessionInformation.order.customer.lastName; state.order.customer.phoneNumber = sessionInformation.order.customer.phoneNumber; - state.order.customer.isSmsOptin = sessionInformation.order.customer.isSmsOptin; + state.order.customer.isSmsOptIn = sessionInformation.order.customer.isSmsOptIn; state.order.existingPromoCode = sessionInformation.order.existingPromoCode; state.applicationUser.experiments = sessionInformation.applicationUser.experiments; @@ -1406,7 +1406,7 @@ export const actions = { emailAddress: order.customer.emailAddress, firstName: order.customer.firstName, lastName: order.customer.lastName, - isSmsOptin: order.customer.isSmsOptin, + isSmsOptIn: order.customer.isSmsOptIn, phoneNumber: order.customer.phoneNumber, }, damage: { diff --git a/src/store/store.spec.js b/src/store/store.spec.js index cecc0f394..626e630eb 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -335,6 +335,28 @@ describe("Mutations", () => { expect(storeState.order.serviceLocation.state).toEqual("OH"); expect(storeState.order.serviceLocation.zipCodeCtu).toEqual("01820"); }); + + it("updateCustomerDetails, should set customer details in state", () => { + // Arrange + const storeState = state; + const customerDetails = { + firstName: "foo", + lastName: "bar", + emailAddress: "foo@bar.com", + phoneNumber: "555-555-5555", + isSmsOptIn: true, + }; + + // Act + mutations.updateCustomerDetails(storeState, customerDetails); + + // Assert + expect(state.order.customer.firstName).toEqual("foo"); + expect(state.order.customer.lastName).toEqual("bar"); + expect(state.order.customer.emailAddress).toEqual("foo@bar.com"); + expect(state.order.customer.phoneNumber).toEqual("555-555-5555"); + expect(state.order.customer.isSmsOptIn).toEqual(true); + }); }); describe("Actions", () => { @@ -938,7 +960,7 @@ describe("Actions", () => { ); }); - it("saveServiceZipCodeInfo, should call mutation and save zip code to state", () => { + it("saveServiceZipCodeInfo, should call mutation", () => { // Arrange const context = state; const commit = jest.fn(); @@ -953,7 +975,6 @@ describe("Actions", () => { // Assert expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceZipCodeInfo); - expect(state.order.serviceLocation.zipCode).toEqual("43212"); }); it("saveServiceZipCodeInfo, should reset if zip code is different", () => { @@ -1022,7 +1043,7 @@ describe("Actions", () => { ); }); - it("saveServiceLocation, should call mutation and save service address to state", () => { + it("saveServiceLocation, should call mutation", () => { // Arrange const context = state; const commit = jest.fn(); @@ -1041,11 +1062,6 @@ describe("Actions", () => { // Assert expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocation); - expect(state.order.serviceLocation.address).toEqual("123 Test Lane"); - expect(state.order.serviceLocation.city).toEqual("Columbus"); - expect(state.order.serviceLocation.zipCode).toEqual("43212"); - expect(state.order.serviceLocation.state).toEqual("OH"); - expect(state.order.serviceLocation.zipCodeCtu).toEqual("01820"); }); it("saveServiceLocation, should reset if zipcode is different", () => { @@ -1292,6 +1308,27 @@ describe("Actions", () => { expect(commit).not.toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE); }); + it.only("saveCustomerDetails, should call mutation", () => { + // Arrange + const context = state; + const commit = jest.fn(); + context.commit = commit; + + const customerDetails = { + firstName: "foo", + lastName: "bar", + emailAddress: "foo@bar.com", + phoneNumber: "555-555-5555", + isSmsOptIn: true, + }; + + // Act + actions.saveCustomerDetails(context, customerDetails); + + // Assert + expect(commit).toBeCalledWith(storeMutations.UPDATE_CUSTOMER_DETAILS, customerDetails); + }); + it("saveGlassParts, should call mutation", () => { // Arrange const context = {