DigitalConsumer.ISS/src/helpers/cms-content-helper.spec.js
Alex Humphries 1149939337 INSR-10111: Address various Copilot comments
- 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
2026-06-29 10:22:14 -04:00

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);
});
});