42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import { toTitleCase, toDisplayPhoneNumber } from '@/helpers/text-helper.js';
|
|
|
|
describe('text-helper', () => {
|
|
test.each([
|
|
[undefined, ''],
|
|
[null, ''],
|
|
['', ''],
|
|
['hello world', 'Hello World'],
|
|
['hello world', 'Hello World'],
|
|
['HEllO worLD', 'Hello World'],
|
|
['a991,,:A froG FAMILY', 'A991,,:a Frog Family']
|
|
])(
|
|
'toTitleCase given "%p" returns "%p"',
|
|
(input, expected) => {
|
|
// Act
|
|
const result = toTitleCase(input);
|
|
|
|
// Assert
|
|
expect(result).toEqual(expected);
|
|
}
|
|
);
|
|
test.each([
|
|
[undefined, ''],
|
|
[null, ''],
|
|
['', ''],
|
|
['119', ''],
|
|
['1111999900', '111-199-9900'],
|
|
['111199-9900', '111-199-9900'],
|
|
['111-199-9900', '111-199-9900'],
|
|
['01111999900', '0-111-199-9900'],
|
|
['0-111-199-9900', '0-111-199-9900']
|
|
])(
|
|
'getDisplayPhoneNumber',
|
|
(input, expected) => {
|
|
// Act
|
|
const result = toDisplayPhoneNumber(input);
|
|
|
|
// Assert
|
|
expect(result).toEqual(expected);
|
|
}
|
|
);
|
|
});
|