DigitalConsumer.ISS/src/helpers/cms-content-helper.spec.js
2024-01-03 19:09:19 -05:00

18 lines
960 B
JavaScript

import { getStringWithCustomValues } 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);
});
});