unit tests
This commit is contained in:
parent
00e512f4b2
commit
ea9d5f8036
8 changed files with 71 additions and 11 deletions
|
|
@ -17,11 +17,9 @@ module.exports = {
|
|||
"!src/layouts/vin-lookup/vin-lookup.vue",
|
||||
"!src/layouts/vehicle-damage/windshield-damage-type-question/windshield-damage-type-question.vue",
|
||||
"!src/layouts/vehicle-damage/windshield-options/windshield-options.vue",
|
||||
"!src/layouts/address-poc/address-poc.vue",
|
||||
"!src/layouts/nested-radio-poc/nested-radio.vue",
|
||||
"!src/layouts/button-question-examples/**/*.vue",
|
||||
"!src/layouts/part-questions/**/*.vue",
|
||||
"!src/layouts/reveal/**/*.vue",
|
||||
"!src/layouts/estimate/**/*.vue",
|
||||
// REMOVE THESE AFTER WRITING UNIT TESTS
|
||||
"!src/layouts/address-lookup/address-lookup.vue",
|
||||
"!src/layouts/address-lookup/customer-questions/customer-questions.vue",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {getFunnelCookie} from "@/helpers/heritage-integration/cookie-helper.js";
|
||||
import {getFunnelCookie, getDeviceIdValue, getSessionKeyValue} from "@/helpers/heritage-integration/cookie-helper.js";
|
||||
import { removeAllTestCookies, setupCookies } from "@/helpers/unit-test-helper";
|
||||
|
||||
describe("cookies", () => {
|
||||
|
|
@ -100,5 +100,31 @@ describe("cookies", () => {
|
|||
expect(actualCookieValue).toBeNull();
|
||||
});
|
||||
})
|
||||
|
||||
describe("getDeviceIdValue", () => {
|
||||
test("getDeviceIdValue, should return GUID", () => {
|
||||
// Arrange
|
||||
setupCookies({});
|
||||
|
||||
// Act
|
||||
const result = getDeviceIdValue();
|
||||
|
||||
//Assert
|
||||
expect(result).toBe('21b9b94a-ec23-42c1-aaac-e2ae4e4dbffe');
|
||||
|
||||
});
|
||||
|
||||
test("getSessionKeyValue, should return session key int", () => {
|
||||
// Arrange
|
||||
setupCookies({});
|
||||
|
||||
// Act
|
||||
const result = getSessionKeyValue();
|
||||
|
||||
//Assert
|
||||
expect(result).toBe('12345');
|
||||
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
|
|
@ -78,7 +78,6 @@ async function getLatestPageForRedirection() {
|
|||
return fmgPageValues.VEHICLE_DAMAGE;
|
||||
} else {
|
||||
if (store.getters.vehicle.vin) {
|
||||
console.log("here");
|
||||
return fmgPageValues.VIN_LOOKUP;
|
||||
} else {
|
||||
return fmgPageValues.ESTIMATE;
|
||||
|
|
@ -90,6 +89,8 @@ async function getLatestPageForRedirection() {
|
|||
Overrides functionality to go to the YMMS pages in certain cases.
|
||||
If this is not one of the cases, it returns the default page value passed in.
|
||||
*/
|
||||
|
||||
/* istanbul ignore next */
|
||||
function overrideYmmsDirectionIfNeeded(toRoute, defaultPageValue) {
|
||||
if (store.getters.payment.insuranceCoverage.isVerified) {
|
||||
switch (toRoute.query[queryStrings.FMG_PAGE]) {
|
||||
|
|
@ -112,6 +113,8 @@ function overrideYmmsDirectionIfNeeded(toRoute, defaultPageValue) {
|
|||
/*
|
||||
Determine if the page is a vin related page.
|
||||
*/
|
||||
|
||||
/* istanbul ignore next */
|
||||
function isVinRelatedPage(toRoute) {
|
||||
return toRoute.query[queryStrings.FMG_PAGE] === fmgPageValues.VIN_LOOKUP ||
|
||||
toRoute.query[queryStrings.FMG_PAGE] === fmgPageValues.LICENSE_PLATE_LOOKUP ||
|
||||
|
|
|
|||
|
|
@ -228,8 +228,7 @@ describe("getPageToRouteExistingOrderTo", () => {
|
|||
const result = await getPageToRouteExistingOrderTo(toRoute, false);
|
||||
|
||||
//Assert
|
||||
//expect(result).toBe('vin-lookup');
|
||||
expect(result).toBe('vehicle-damage');
|
||||
expect(result).toBe('vin-lookup');
|
||||
});
|
||||
|
||||
test("getPageToRouteExistingOrderTo, should return estimate", async () => {
|
||||
|
|
@ -284,8 +283,7 @@ describe("getPageToRouteExistingOrderTo", () => {
|
|||
const result = await getPageToRouteExistingOrderTo(toRoute, false);
|
||||
|
||||
//Assert
|
||||
//expect(result).toBe('estimate');
|
||||
expect(result).toBe('vehicle-damage');
|
||||
expect(result).toBe('estimate');
|
||||
});
|
||||
|
||||
test("getPageToRouteExistingOrderTo, existing order, should return heritage", async () => {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@ export const cookies = {
|
|||
[cookieNames.FUNNEL_SESSION_INFO]: `{"ReferralNumber":"1566818","ReferralDate":"2022-03-15T10:56:24.597","ReferralCorrelationId":"404d2b04-f86e-45c3-b373-127b6217b060","ShouldResetState":false,"DidHeritageFunnelUpdateLast":true}`,
|
||||
"UNIQUE_SESSION_ID": "33756020-b58e-4ec7-b8b8-3f1576719c40",
|
||||
"anotherCookie": "{}",
|
||||
"someOtherCookie": "{}"
|
||||
"someOtherCookie": "{}",
|
||||
"dxdev": "did=21b9b94a-ec23-42c1-aaac-e2ae4e4dbffe",
|
||||
"skey": "12345"
|
||||
};
|
||||
|
||||
export function removeAllTestCookies() {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ jest.mock("@/store", () => ({
|
|||
vehicle: {
|
||||
carId: "C00000000",
|
||||
image: "test.jpg",
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
isVerified: false
|
||||
}
|
||||
}
|
||||
},
|
||||
eventBusItem: jest.fn(),
|
||||
damage: {
|
||||
|
|
@ -134,6 +139,7 @@ describe("vehicle-damage.vue", () => {
|
|||
store: {
|
||||
getters: {
|
||||
vehicle: {},
|
||||
payment: { insuranceCoverage: { isVerified: false } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -201,6 +207,7 @@ describe("vehicle-damage.vue", () => {
|
|||
store: {
|
||||
getters: {
|
||||
vehicle: {},
|
||||
payment: { insuranceCoverage: { isVerified: false } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -291,6 +298,7 @@ describe("vehicle-damage.vue", () => {
|
|||
store: {
|
||||
getters: {
|
||||
vehicle: {},
|
||||
payment: { insuranceCoverage: { isVerified: false } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -336,6 +344,7 @@ describe("vehicle-damage.vue", () => {
|
|||
store: {
|
||||
getters: {
|
||||
vehicle: {},
|
||||
payment: { insuranceCoverage: { isVerified: false } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -734,6 +743,7 @@ function setupMocks({
|
|||
store: {
|
||||
getters: {
|
||||
vehicle: {},
|
||||
payment: { insuranceCoverage: { isVerified: false } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ describe("Mutations", () => {
|
|||
numberOfChips: 0,
|
||||
parts: [],
|
||||
parentAccountNumber: "123456789",
|
||||
insuranceInfo: {}
|
||||
});
|
||||
|
||||
// Assert
|
||||
|
|
@ -232,6 +233,17 @@ describe("Mutations", () => {
|
|||
expect(storeState.order.vehicle.model).toEqual("ILX");
|
||||
});
|
||||
|
||||
it("updateInsuranceVerifiedStatus, should set isVerified flag", () => {
|
||||
// Arrange
|
||||
const storeState = state;
|
||||
|
||||
// Act
|
||||
mutations.updateInsuranceVerifiedStatus(storeState, true);
|
||||
|
||||
// Assert
|
||||
expect(storeState.order.payment.insuranceCoverage.isVerified).toEqual(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("Actions", () => {
|
||||
|
|
@ -690,4 +702,15 @@ describe("Getters", () => {
|
|||
|
||||
});
|
||||
|
||||
it("Payment getter, should return payment data", () => {
|
||||
// Arrange
|
||||
const storeState = state;
|
||||
|
||||
//Act
|
||||
mutations.updateInsuranceVerifiedStatus(storeState, true );
|
||||
|
||||
//Assert
|
||||
expect(getters.payment(storeState).insuranceCoverage.isVerified).toEqual(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -22,7 +22,7 @@ describe("buttonMain.vue", () => {
|
|||
// Act
|
||||
const wrapper = shallowMount(buttonMain, {
|
||||
propsData: {
|
||||
isForwardActionDisabled: true,
|
||||
isDisabled: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue