- Add unit tests for mapStringToPhoneNumber function - Remove console.log from mapStringToPhoneNumber function - Update welcome-page.vue to await getCarrierAccountInfo() in setup() - getCarrierAccountInfo() again when submitting order, in case of account# change - Change import for toDisplayPhoneNumber to use absolute path
28 lines
1.3 KiB
JavaScript
28 lines
1.3 KiB
JavaScript
import { getStringWithCustomValues, mapStringToPhoneNumber } from '@/helpers/cms-content-helper.js';
|
|
|
|
describe('getStringWithCustomValues', () => {
|
|
test.each([
|
|
['Hello, {custom:name}!', { name: 'John' }, 'Hello, John!'],
|
|
['{custom:greeting}, {custom:name}!', { greeting: 'Hi', name: 'John' }, 'Hi, John!'],
|
|
['{custom:greeting}, {custom:name}!', { greeting: 'Hi' }, 'Hi, {custom:name}!'],
|
|
['Hello, {custom:name}!', {}, 'Hello, {custom:name}!'],
|
|
['Hello, world!', { name: 'John' }, 'Hello, world!'],
|
|
['', { name: 'John' }, ''],
|
|
['Hello, {custom:name}!', null, 'Hello, {custom:name}!'],
|
|
['Hello, {custom:name}!', undefined, 'Hello, {custom:name}!'],
|
|
[null, { name: 'John' }, ''],
|
|
[undefined, { name: 'John' }, '']
|
|
])('getStringWithCustomValues(%s, %o) should return %s', (str, customValueMap, expected) => {
|
|
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);
|
|
});
|
|
});
|