Merge branch 'develop' into feature/jzimmerman/INSR-10176
This commit is contained in:
commit
517c4a673b
5 changed files with 37 additions and 36 deletions
|
|
@ -5,7 +5,8 @@ const dynamicStrings = Object.freeze({
|
|||
MODAL_LINK: 'modalLink',
|
||||
TEXT_LINK: 'textLink',
|
||||
EXTERNAL_LINK: 'externalLink',
|
||||
PHONE_LINK: 'phoneLink'
|
||||
PHONE_LINK: 'phoneLink',
|
||||
PHONE_NUMBER: 'phoneNumber'
|
||||
});
|
||||
|
||||
export default dynamicStrings;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import dynamicStrings from '@/constants/dynamic-strings';
|
||||
import { useMainStore } from '@/store';
|
||||
import { toDisplayPhoneNumber } from '@/helpers/text-helper';
|
||||
|
||||
/**
|
||||
* @function getStringWithCustomValues
|
||||
|
|
@ -45,6 +46,9 @@ function processWidgetItemForReplacement(widgetModel, key) {
|
|||
if (widgetModel[key].includes(dynamicStrings.GLOBAL_STATE)) {
|
||||
widgetModel[key] = mapStringToState(widgetModel[key]);
|
||||
}
|
||||
if (widgetModel[key].includes(dynamicStrings.PHONE_NUMBER)) {
|
||||
widgetModel[key] = mapStringToPhoneNumber(widgetModel[key]);
|
||||
}
|
||||
return widgetModel[key];
|
||||
}
|
||||
|
||||
|
|
@ -317,6 +321,19 @@ function mapStringToState(str) {
|
|||
return str.trimStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @function mapStringToPhoneNumber
|
||||
* @param str
|
||||
*/
|
||||
export function mapStringToPhoneNumber(str) {
|
||||
// Expected token format: {phoneNumber:##########} (or 11 digits).
|
||||
const regexExp = new RegExp(`\\{${dynamicStrings.PHONE_NUMBER}:([^}]*)\\}`, 'g');
|
||||
return str.replace(regexExp, (_match, rawValue) => {
|
||||
const digits = (rawValue.match(/\d+/g) ?? []).join('');
|
||||
return toDisplayPhoneNumber(digits);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @function getStoreValueFromString
|
||||
* @param str
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { getStringWithCustomValues } from '@/helpers/cms-content-helper.js';
|
||||
import { getStringWithCustomValues, mapStringToPhoneNumber } from '@/helpers/cms-content-helper.js';
|
||||
|
||||
describe('getStringWithCustomValues', () => {
|
||||
test.each([
|
||||
|
|
@ -16,3 +16,13 @@ describe('getStringWithCustomValues', () => {
|
|||
expect(getStringWithCustomValues(str, customValueMap)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mapStringToPhoneNumber', () => {
|
||||
test.each([
|
||||
['{phoneNumber:1234567890}', '123-456-7890'],
|
||||
['{phoneNumber:12345678901}', '1-234-567-8901'],
|
||||
['{phoneNumber:123}', ''],
|
||||
])('mapStringToPhoneNumber(%s) should return %s', (str, expected) => {
|
||||
expect(mapStringToPhoneNumber(str)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@ function setupMocks({
|
|||
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||
|
||||
const mountOptions = getMountOptions(mockDataMountOptions);
|
||||
useMainStore().getCarrierAccountInfo = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
data: {
|
||||
phoneNumber: '1234567890'
|
||||
}
|
||||
}));
|
||||
|
||||
const wrapper = shallowMount(welcomePage, mountOptions);
|
||||
|
||||
|
|
@ -91,39 +96,6 @@ function setupMocks({
|
|||
return { wrapper, apiPromise };
|
||||
}
|
||||
|
||||
function getMountedComponent(mainInitialState = {}, initialData = {}) {
|
||||
const mountOptions = getMountOptions({
|
||||
router: {
|
||||
navigate: jest.fn()
|
||||
}
|
||||
});
|
||||
|
||||
mountOptions.global.stubs = {
|
||||
siteHeader: true,
|
||||
recalModal: true,
|
||||
contentGroupModal: true,
|
||||
alert: true
|
||||
};
|
||||
mountOptions.global.plugins = [createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
})];
|
||||
mountOptions.data = () => (
|
||||
initialData
|
||||
);
|
||||
|
||||
const apiResponses = {
|
||||
supportingItems: []
|
||||
};
|
||||
const apiPromise = Promise.resolve(apiResponses);
|
||||
settleAllPromises.mockImplementation(() => apiPromise);
|
||||
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||
|
||||
const wrapper = shallowMount(welcomePage, mountOptions);
|
||||
return { wrapper };
|
||||
}
|
||||
|
||||
describe('welcome-page.vue', () => {
|
||||
test('Should render welcomePage sub-components (policyNumber, policyZipCode, dateOfLoss, damageCause etc.)', async () => {
|
||||
// Arrange
|
||||
|
|
@ -180,7 +152,7 @@ describe('navigation', () => {
|
|||
describe('When zip code check succeeds', () => {
|
||||
test('if duplicates found, navigate to duplicate check page', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent({});
|
||||
const { wrapper } = setupMocks({});
|
||||
useMainStore().getDuplicateReferrals = jest.fn().mockImplementation(() => Promise.resolve({}));
|
||||
useMainStore().applicationUser.duplicateOrders = [{ test: 'a' }];
|
||||
wrapper.vm.mainStore.validateZip = jest.fn().mockImplementation(() => Promise.resolve({
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ export default {
|
|||
|
||||
// Set order account number from the issConfig.
|
||||
mainStore.order.parentAccountNumber = mainStore.issConfig.parentAccountNumber;
|
||||
mainStore.getCarrierAccountInfo().catch((error) => console.error('Error in getCarrierAccountInfo', error));
|
||||
|
||||
return { mainStore };
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue