CSR-98 Add tests
This commit is contained in:
parent
2b6d22fd71
commit
d6eb6e0353
4 changed files with 252 additions and 187 deletions
|
|
@ -8,13 +8,9 @@ import baseMixin from "../mixins/base-mixin";
|
|||
|
||||
// Read info from heritage funnel and reset state or load referral
|
||||
export function handleInfoFromHeritageFunnel() {
|
||||
const orderInfo = getHeritageCookieValue();
|
||||
console.log("A")
|
||||
console.log(orderInfo)
|
||||
console.log(document.cookie)
|
||||
const orderInfo = this.getHeritageCookieValue();
|
||||
|
||||
if (orderInfo?.ShouldResetState) {
|
||||
console.log("B")
|
||||
store.dispatch(storeActions.RESET_STATE);
|
||||
deleteHeritageCookie();
|
||||
}
|
||||
|
|
@ -25,12 +21,10 @@ export function handleInfoFromHeritageFunnel() {
|
|||
// ShouldResetState: false
|
||||
// })
|
||||
}
|
||||
|
||||
console.log("D")
|
||||
}
|
||||
|
||||
export async function navigateToHeritageFunnel() {
|
||||
await saveOrder();
|
||||
await this.saveOrder();
|
||||
const referralCorrelationId = store.getters.referralCorrelationId;
|
||||
|
||||
router.navigate(
|
||||
|
|
@ -47,7 +41,6 @@ export async function navigateToHeritageFunnel() {
|
|||
}
|
||||
|
||||
export async function saveOrder() {
|
||||
console.log("HI")
|
||||
const savedOrderInfo = (await baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.SAVE_ORDER)).data;
|
||||
store.commit(storeMutations.UPDATE_REFERRAL_NUMBER, savedOrderInfo.referralNumber);
|
||||
store.commit(storeMutations.UPDATE_REFERRAL_DATE, savedOrderInfo.referralDate);
|
||||
|
|
@ -60,7 +53,6 @@ export async function saveOrder() {
|
|||
|
||||
/* Start cookie related functions */
|
||||
export function getHeritageCookieValue() {
|
||||
console.log("A")
|
||||
const cookieJson = document.cookie
|
||||
?.split("; ")
|
||||
?.find(row => row.startsWith(`${cookieNames.ORDER_INFO}=`))
|
||||
|
|
|
|||
|
|
@ -4,73 +4,86 @@ import { setupMocksForJsFiles } from "@/helpers/unit-test-helper.js";
|
|||
import { storeActions } from "@/constants/store-actions";
|
||||
import { storeMutations } from "@/constants/store-mutations";
|
||||
import store from "@/store";
|
||||
import router from "@/router";
|
||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||
describe("handleInfoFromHeritageFunnel", () => {
|
||||
afterEach(() => {
|
||||
removeAllTestCookies();
|
||||
});
|
||||
|
||||
test("ShouldResetState == true => heritage cookie is deleted", () => {
|
||||
// Arrange
|
||||
const testShouldResetState = true;
|
||||
|
||||
const testCookieValue = {
|
||||
ShouldResetState: testShouldResetState
|
||||
}
|
||||
|
||||
document.cookie = `${cookieNames.ORDER_INFO}=${JSON.stringify(testCookieValue)}; path=/; domain=${location.hostname}`;
|
||||
|
||||
// Act
|
||||
helper.handleInfoFromHeritageFunnel();
|
||||
|
||||
// Assert
|
||||
expect(document.cookie).toBe("");
|
||||
});
|
||||
|
||||
test("ShouldResetState == true => reset store", () => {
|
||||
// Arrange
|
||||
const getHeritageCookieValueMethod = jest.spyOn(helper, "getHeritageCookieValue")
|
||||
getHeritageCookieValueMethod.mockImplementation(() => { return { ShouldResetState: true, DidHeritageFunnelUpdateLast: false } });
|
||||
|
||||
const mockData = {
|
||||
actionList: [{
|
||||
actionName: storeActions.RESET_STATE
|
||||
}],
|
||||
}
|
||||
|
||||
setupMocksForJsFiles(mockData);
|
||||
store.dispatch = jest.spyOn(store, "dispatch");
|
||||
|
||||
// Act
|
||||
helper.handleInfoFromHeritageFunnel();
|
||||
|
||||
// Assert
|
||||
expect(getHeritageCookieValueMethod).toHaveBeenCalled();
|
||||
expect(store.dispatch).toHaveBeenCalledWith(storeActions.RESET_STATE);
|
||||
|
||||
getHeritageCookieValueMethod.mockRestore();
|
||||
store.dispatch.mockRestore();
|
||||
});
|
||||
|
||||
test("Heritage cookie is null => store is unchanged", () => {
|
||||
// Arrange
|
||||
const getHeritageCookieValueMethod = jest.spyOn(helper, "getHeritageCookieValue")
|
||||
getHeritageCookieValueMethod.mockImplementation(() => null);
|
||||
|
||||
store.dispatch = jest.spyOn(store, "dispatch");
|
||||
|
||||
const mockData = {
|
||||
actionList: [{
|
||||
actionName: storeActions.RESET_STATE
|
||||
}],
|
||||
}
|
||||
|
||||
setupMocksForJsFiles(mockData);
|
||||
|
||||
// Act
|
||||
helper.handleInfoFromHeritageFunnel();
|
||||
|
||||
// Assert
|
||||
expect(helper.getHeritageCookieValue).toHaveBeenCalled();
|
||||
expect(store.dispatch).not.toHaveBeenCalledWith(storeActions.RESET_STATE);
|
||||
|
||||
getHeritageCookieValueMethod.mockRestore();
|
||||
store.dispatch.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
describe("saveOrder", () => {
|
||||
|
||||
// afterEach(() => {
|
||||
// removeAllTestCookies();
|
||||
// });
|
||||
|
||||
function getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate ) {
|
||||
return {
|
||||
referralNumber: mockReferralNumber,
|
||||
referralCorrelationId: mockCorrelationId,
|
||||
referralDate: mockReferralDate
|
||||
}
|
||||
}
|
||||
|
||||
describe("handleInfoFromHeritageFunnel", () => {
|
||||
// test("ShouldResetState == true => heritage cookie is deleted", () => {
|
||||
// // Arrange
|
||||
// // TODO CSR-98 Can we not mock this??
|
||||
// const testShouldResetState = true;
|
||||
|
||||
// const testCookieValue = {
|
||||
// ShouldResetState: testShouldResetState
|
||||
// }
|
||||
|
||||
// console.log(cookieNames.ORDER_INFO);
|
||||
// console.log(testCookieValue)
|
||||
// console.log(JSON.stringify(testCookieValue));
|
||||
// console.log(location.hostname)
|
||||
// let myString = `${cookieNames.ORDER_INFO}=${JSON.stringify(testCookieValue)};domain=${location.hostname};path=/;`;
|
||||
// console.log(myString)
|
||||
// document.cookie = 'OrderInfo={"Hahahah":true};domain=localhost;path=/;';
|
||||
// console.log(document.cookie)
|
||||
// document.cookie = "Ahhh=AHHH;"
|
||||
// document.cookie = `${cookieNames.ORDER_INFO}=; Max-Age=0; domain=${location.hostname};`;
|
||||
// console.log(document.cookie)
|
||||
|
||||
// // Act
|
||||
// helper.handleInfoFromHeritageFunnel();
|
||||
|
||||
// // Assert
|
||||
// console.log(document.cookie)
|
||||
// // expect(document.cookie).toBe();
|
||||
// });
|
||||
|
||||
// test("ShouldResetState == true => reset store", () => {
|
||||
// // Arrange
|
||||
// helper.getHeritageCookieValue = jest.fn(x => x.ShouldResetState = false);
|
||||
|
||||
// // Act
|
||||
// helper.handleInfoFromHeritageFunnel();
|
||||
|
||||
// // Assert
|
||||
// expect(helper.getHeritageCookieValue).toHaveBeenCalled();
|
||||
// });
|
||||
|
||||
// test("Heritage cookie is null => store is unchanged", () => {
|
||||
// // Arrange
|
||||
// helper.getHeritageCookieValue = jest.fn(x => x.ShouldResetState = true);
|
||||
|
||||
// // Act
|
||||
// helper.handleInfoFromHeritageFunnel();
|
||||
|
||||
// // Assert
|
||||
// expect(helper.getHeritageCookieValue).toHaveBeenCalled();
|
||||
// });
|
||||
});
|
||||
afterEach(() => {
|
||||
removeAllTestCookies();
|
||||
});
|
||||
|
||||
test("saveOrder => should set state order values", async () => {
|
||||
// Arrange
|
||||
|
|
@ -79,16 +92,18 @@ describe("saveOrder", () => {
|
|||
const mockReferralDate = "2022";
|
||||
|
||||
const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate);
|
||||
|
||||
|
||||
const mockData = {
|
||||
actionList: [{
|
||||
actionName: storeActions.SAVE_ORDER,
|
||||
data: mockOrderInfo,
|
||||
actionList: [{
|
||||
actionName: storeActions.SAVE_ORDER,
|
||||
data: mockOrderInfo,
|
||||
}],
|
||||
router: router
|
||||
}
|
||||
|
||||
setupMocksForJsFiles(mockData);
|
||||
|
||||
setupMocksForJsFiles(mockData);
|
||||
store.commit = jest.spyOn(store, "commit");
|
||||
|
||||
// Act
|
||||
await helper.saveOrder();
|
||||
|
||||
|
|
@ -97,48 +112,110 @@ describe("saveOrder", () => {
|
|||
expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_REFERRAL_NUMBER, mockReferralNumber);
|
||||
expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, mockCorrelationId);
|
||||
expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_REFERRAL_DATE, mockReferralDate);
|
||||
store.commit.mockRestore();
|
||||
});
|
||||
|
||||
// test("saveOrder => should update DidHeritageFunnelUpdateLast cookie value", async () => {
|
||||
// // Arrange
|
||||
// const mockReferralNumber = 2;
|
||||
// const mockCorrelationId = "55";
|
||||
// const mockReferralDate = "2022";
|
||||
test("saveOrder => should update DidHeritageFunnelUpdateLast cookie value to false", async () => {
|
||||
// Arrange
|
||||
const testReferralNumber = 1566818;
|
||||
const testReferralDate = "2022-03-15T10:56:24.597";
|
||||
const testReferralCorrelationId = "404d2b04-f86e-45c3-b373-127b6217b060";
|
||||
|
||||
// const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate);
|
||||
|
||||
// const mockData = {
|
||||
// actionList: [{
|
||||
// actionName: storeActions.SAVE_ORDER,
|
||||
// data: mockOrderInfo,
|
||||
// }],
|
||||
// }
|
||||
|
||||
// setupMocksForJsFiles(mockData);
|
||||
|
||||
// // Act
|
||||
// await helper.saveOrder();
|
||||
const mockOrderInfo = getMockOrderInfo(testReferralNumber, testReferralCorrelationId, testReferralDate);
|
||||
|
||||
// // Assert
|
||||
|
||||
// });
|
||||
const mockData = {
|
||||
actionList: [{
|
||||
actionName: storeActions.SAVE_ORDER,
|
||||
data: mockOrderInfo,
|
||||
}],
|
||||
router: router
|
||||
}
|
||||
|
||||
setupMocksForJsFiles(mockData);
|
||||
|
||||
const testCookieValue = {
|
||||
ReferralNumber: testReferralNumber,
|
||||
ReferralDate: testReferralDate,
|
||||
ReferralCorrelationId: testReferralCorrelationId,
|
||||
ShouldResetState: false,
|
||||
DidHeritageFunnelUpdateLast: true
|
||||
}
|
||||
|
||||
setupCookies({ heritageCookieValue: JSON.stringify(testCookieValue) });
|
||||
|
||||
// Act
|
||||
await helper.saveOrder();
|
||||
|
||||
// Assert
|
||||
expect(helper.getHeritageCookieValue().DidHeritageFunnelUpdateLast).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("navigateToHeritageFunnel", () => {
|
||||
test("should go to external link", () => {
|
||||
test("should save order", async () => {
|
||||
// Arrange
|
||||
const mockReferralNumber = 2;
|
||||
const mockCorrelationId = "55";
|
||||
const mockReferralDate = "2022";
|
||||
|
||||
const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate);
|
||||
|
||||
const mockData = {
|
||||
actionList: [{
|
||||
actionName: storeActions.SAVE_ORDER,
|
||||
data: mockOrderInfo,
|
||||
}],
|
||||
router: router
|
||||
}
|
||||
|
||||
setupMocksForJsFiles(mockData);
|
||||
const saveOrderFunction = jest.spyOn(helper, "saveOrder");
|
||||
|
||||
// Act
|
||||
helper.navigateToHeritageFunnel();
|
||||
await helper.navigateToHeritageFunnel();
|
||||
|
||||
// Assert
|
||||
expect(saveOrderFunction).toHaveBeenCalled();
|
||||
|
||||
// Should alway save before we navigate to heritage
|
||||
const saveOrderFunctionCallOrder = saveOrderFunction.mock.invocationCallOrder[0];
|
||||
const routerNavigateFunctionCallOrder = router.navigate.mock.invocationCallOrder[0];
|
||||
expect(saveOrderFunctionCallOrder).toBeLessThan(routerNavigateFunctionCallOrder);
|
||||
saveOrderFunction.mockRestore();
|
||||
});
|
||||
|
||||
test("should go to heritage funnel", async () => {
|
||||
// Arrange
|
||||
const mockReferralNumber = 2;
|
||||
const mockCorrelationId = "55";
|
||||
const mockReferralDate = "2022";
|
||||
|
||||
const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate);
|
||||
|
||||
const mockData = {
|
||||
actionList: [{
|
||||
actionName: storeActions.SAVE_ORDER,
|
||||
data: mockOrderInfo,
|
||||
}],
|
||||
router: router
|
||||
}
|
||||
|
||||
setupMocksForJsFiles(mockData);
|
||||
|
||||
// Act
|
||||
await helper.navigateToHeritageFunnel();
|
||||
|
||||
// Assert
|
||||
expect(router.navigate).toHaveBeenCalled();
|
||||
expect(window.location.assign).toHaveBeenCalled();
|
||||
})
|
||||
expect(router.navigate).toHaveBeenCalledWith(navigationScenarios.MOVE_TO_HERITAGE_FUNNEL, expect.anything(),
|
||||
expect.objectContaining({
|
||||
corid: mockCorrelationId
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO CSR-98 Remove skip
|
||||
describe.skip("cookies", () => {
|
||||
describe("cookies", () => {
|
||||
afterEach(() => {
|
||||
removeAllTestCookies();
|
||||
})
|
||||
|
|
@ -172,7 +249,7 @@ describe.skip("cookies", () => {
|
|||
expect(result.ReferralCorrelationId).toEqual(testReferralCorrelationId);
|
||||
expect(result.ShouldResetState).toEqual(testShouldResetState);
|
||||
expect(result.DidHeritageFunnelUpdateLast).toEqual(testDidHeritageFunnelUpdateLast);
|
||||
})
|
||||
});
|
||||
|
||||
test("returns empty object when value is empty object", () => {
|
||||
// Arrange
|
||||
|
|
@ -186,7 +263,7 @@ describe.skip("cookies", () => {
|
|||
expect(result).toEqual(testCookieValue);
|
||||
expect(typeof result).toEqual("object");
|
||||
expect(Object.keys(result)).toHaveLength(0);
|
||||
})
|
||||
});
|
||||
|
||||
test("returns null when value is empty string", () => {
|
||||
// Arrange
|
||||
|
|
@ -198,7 +275,7 @@ describe.skip("cookies", () => {
|
|||
|
||||
// Assert
|
||||
expect(result).toEqual(null);
|
||||
})
|
||||
});
|
||||
|
||||
test("returns null when heritage cookie doesn't exist", () => {
|
||||
// Arrange
|
||||
|
|
@ -209,7 +286,31 @@ describe.skip("cookies", () => {
|
|||
|
||||
// Assert
|
||||
expect(result).toEqual(null);
|
||||
})
|
||||
});
|
||||
|
||||
test("gets correct cookie value", () => {
|
||||
// Arrange
|
||||
const testCookieValue = { test: "testValue" };
|
||||
|
||||
setupCookies({ heritageCookieValue: JSON.stringify(testCookieValue) });
|
||||
|
||||
// Act
|
||||
const actualCookieValue = helper.getHeritageCookieValue();
|
||||
|
||||
// Assert
|
||||
expect(actualCookieValue).toEqual(testCookieValue);
|
||||
});
|
||||
|
||||
test("getCookieValue: Gets null cookie value", () => {
|
||||
// Arrange
|
||||
setupCookies({ includeHeritageCookie: false });
|
||||
|
||||
// Act
|
||||
const actualCookieValue = helper.getHeritageCookieValue();
|
||||
|
||||
// Assert
|
||||
expect(actualCookieValue).toBeNull();
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -225,58 +326,25 @@ const cookies = {
|
|||
};
|
||||
|
||||
function setupCookies({ heritageCookieValue = "", includeHeritageCookie = true }) {
|
||||
console.log(heritageCookieValue)
|
||||
Object.keys(cookies).forEach(key => {
|
||||
const cookieValue = key == cookieNames.ORDER_INFO ? heritageCookieValue : cookies[key];
|
||||
|
||||
|
||||
if (includeHeritageCookie || key != cookieNames.ORDER_INFO)
|
||||
document.cookie = `${key}=${cookieValue}`;
|
||||
document.cookie = `${key}=${cookieValue}; path=/;`;
|
||||
});
|
||||
}
|
||||
|
||||
function removeAllTestCookies() {
|
||||
Object.keys(cookies).forEach(key => {
|
||||
document.cookie = `${key}=;Max-Age=0;`;
|
||||
document.cookie = `${key}=;Max-Age=0;path=/`;
|
||||
});
|
||||
}
|
||||
|
||||
// test("getCookieValue: Gets correct cookie value", () => {
|
||||
// // Arrange
|
||||
// const mixIn = getMixInInstance({});
|
||||
// const testCookieName = "testCookie";
|
||||
// const testCookieValue = "testCookieValue";
|
||||
|
||||
// document.cookie = `yearMakeModel=2020 ACURA MDX;`;
|
||||
// document.cookie = `SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6;`;
|
||||
// document.cookie = `${testCookieName}=${testCookieValue};`;
|
||||
// document.cookie = `EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED;`;
|
||||
// document.cookie = `orderconfirmation=7411543;`;
|
||||
|
||||
// console.log(document.cookie)
|
||||
|
||||
// // Act
|
||||
// const actualCookieValue = mixIn.methods.getCookieValue(testCookieName);
|
||||
|
||||
// // Assert
|
||||
// expect(actualCookieValue).toEqual(testCookieValue);
|
||||
// expect(document.cookie).toEqual(`yearMakeModel=2020 ACURA MDX; SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6; ${testCookieName}=${testCookieValue}; EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED; orderconfirmation=7411543`);
|
||||
// clearCookies();
|
||||
// });
|
||||
|
||||
// test("getCookieValue: Gets undefined cookie value", () => {
|
||||
// // Arrange
|
||||
// const mixIn = getMixInInstance({});
|
||||
// const testCookieName = "testCookie";
|
||||
|
||||
// document.cookie = `yearMakeModel=2020 ACURA MDX;`;
|
||||
// document.cookie = `SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6;`;
|
||||
// document.cookie = `EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED;`;
|
||||
// document.cookie = `orderconfirmation=7411543;`;
|
||||
|
||||
// // Act
|
||||
// const actualCookieValue = mixIn.methods.getCookieValue(testCookieName);
|
||||
|
||||
// // Assert
|
||||
// expect(actualCookieValue).toEqual(undefined);
|
||||
// expect(document.cookie).toEqual(`yearMakeModel=2020 ACURA MDX; SavedQuoteID=d2770645-0680-4852-9649-6170659b1bd6; EMBEDDEDPAYMENTPAGE_PAYPAL_SUBMITBUTTON=COMPLETED; orderconfirmation=7411543;`);
|
||||
// });
|
||||
function getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate) {
|
||||
return {
|
||||
referralNumber: mockReferralNumber,
|
||||
referralCorrelationId: mockCorrelationId,
|
||||
referralDate: mockReferralDate
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,29 +4,31 @@ import { navigationScenarios } from "@/router/router-constants/navigation-scenar
|
|||
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
||||
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
||||
import baseMixin from "@/mixins/base-mixin";
|
||||
import store from "@/store";
|
||||
|
||||
export function getMountOptions(mockData) {
|
||||
// Define our mocks to attached to the 'global' object for Vue/Jest.
|
||||
const mocks = {};
|
||||
|
||||
//this is mocking if you use the mixin directly(baseMixin.methods.dispatchNonBlockingStoreAction) vs this.dispatchNonBlockingStoreAction
|
||||
if (mockData.actionList !== undefined) {
|
||||
// baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn();
|
||||
// baseMixin.methods.dispatchNonBlockingStoreAction.mockImplementation((actionName) => {
|
||||
// let actionFilterResult = mockData.actionList.filter(
|
||||
// (x) => x.actionName == actionName
|
||||
// );
|
||||
setupBaseMixinDispatchNonBlockingStoreAction(mockData);
|
||||
// if (mockData.actionList !== undefined) {
|
||||
// // baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn();
|
||||
// // baseMixin.methods.dispatchNonBlockingStoreAction.mockImplementation((actionName) => {
|
||||
// // let actionFilterResult = mockData.actionList.filter(
|
||||
// // (x) => x.actionName == actionName
|
||||
// // );
|
||||
|
||||
// if (actionFilterResult.length > 0 && actionFilterResult.length === 1) {
|
||||
// return Promise.resolve({
|
||||
// data: actionFilterResult[0].data,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// // if (actionFilterResult.length > 0 && actionFilterResult.length === 1) {
|
||||
// // return Promise.resolve({
|
||||
// // data: actionFilterResult[0].data,
|
||||
// // });
|
||||
// // }
|
||||
// // });
|
||||
|
||||
setupDispatchNonBlockingStoreAction(mockData);
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
|
||||
mocks.dispatchNonBlockingStoreAction = jest.fn();
|
||||
mocks.dispatchNonBlockingStoreAction.mockImplementation((actionName) => {
|
||||
let actionFilterResult = mockData.actionList.filter(
|
||||
|
|
@ -59,23 +61,26 @@ export function getMountOptions(mockData) {
|
|||
return { global };
|
||||
}
|
||||
|
||||
function setupDispatchNonBlockingStoreAction(mockData) {
|
||||
function setupBaseMixinDispatchNonBlockingStoreAction(mockData) {
|
||||
baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn();
|
||||
baseMixin.methods.dispatchNonBlockingStoreAction.mockImplementation((actionName) => {
|
||||
let actionFilterResult = mockData.actionList.filter(
|
||||
(x) => x.actionName == actionName
|
||||
);
|
||||
|
||||
if (actionFilterResult.length > 0 && actionFilterResult.length === 1) {
|
||||
return Promise.resolve({
|
||||
data: actionFilterResult[0].data,
|
||||
});
|
||||
}
|
||||
});
|
||||
if (mockData.actionList !== undefined) {
|
||||
baseMixin.methods.dispatchNonBlockingStoreAction.mockImplementation((actionName) => {
|
||||
let actionFilterResult = mockData.actionList.filter(
|
||||
(x) => x.actionName == actionName
|
||||
);
|
||||
|
||||
if (actionFilterResult.length > 0 && actionFilterResult.length === 1) {
|
||||
return Promise.resolve({
|
||||
data: actionFilterResult[0].data,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function setupMocksForJsFiles(mockData) {
|
||||
setupDispatchNonBlockingStoreAction(mockData);
|
||||
store.commit = jest.fn();
|
||||
router.navigate = jest.fn();
|
||||
export function setupMocksForJsFiles(mockData = {}) {
|
||||
setupBaseMixinDispatchNonBlockingStoreAction(mockData);
|
||||
|
||||
if (mockData.router)
|
||||
mockData.router.navigate = jest.fn();
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ async function navigate(scenario, currentRoute, invalidateOnSave, optionalQuery
|
|||
// Append page data to the store for the NEXT page, if any. It will be an empty object if none is provided.
|
||||
baseMixin.methods.savePageDataToStore(destinationFmgPageValue, optionalPageData);
|
||||
|
||||
// if cookie and referralNumber exists
|
||||
// if cookie and referral exists
|
||||
if (getHeritageCookieValue()?.ReferralNumber)
|
||||
saveOrder();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue