+1
-1
@@ -21,7 +21,7 @@ export function prettifyTitle(input?: string): string | undefined {
|
|||||||
if (!input) {
|
if (!input) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const words = input.split(/[_\s]+/);
|
const words = input.trim().split(/[_\s]+/);
|
||||||
return words
|
return words
|
||||||
.map((word) => {
|
.map((word) => {
|
||||||
return word[0].toUpperCase() + word.substring(1);
|
return word[0].toUpperCase() + word.substring(1);
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ describe('prettifyTitle', () => {
|
|||||||
it('should prettify words', () => {
|
it('should prettify words', () => {
|
||||||
expect(prettifyTitle('this is_a string')).toBe('This Is A String');
|
expect(prettifyTitle('this is_a string')).toBe('This Is A String');
|
||||||
});
|
});
|
||||||
|
it('should handle leading spaces', () => {
|
||||||
|
expect(prettifyTitle(' this is_a string')).toBe('This Is A String');
|
||||||
|
});
|
||||||
|
it('should handle empty string', () => {
|
||||||
|
expect(prettifyTitle('')).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('arrayMove', () => {
|
describe('arrayMove', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user