Commit 99a5c4b9 authored by Kushal Pandya's avatar Kushal Pandya

Add `convertToCamelCase` helper method

parent f718d641
......@@ -73,3 +73,10 @@ export function capitalizeFirstCharacter(text) {
* @returns {String}
*/
export const stripHtml = (string, replace = '') => string.replace(/<[^>]*>/g, replace);
/**
* Converts snake_case string to camelCase
*
* @param {*} string
*/
export const convertToCamelCase = string => string.replace(/(_\w)/g, s => s[1].toUpperCase());
......@@ -72,4 +72,10 @@ describe('text_utility', () => {
expect(textUtils.stripHtml('This is a text with <p>html</p>.', ' ')).toEqual('This is a text with html .');
});
});
describe('convertToCamelCase', () => {
it('converts snake_case string to camelCase string', () => {
expect(textUtils.convertToCamelCase('snake_case')).toBe('snakeCase');
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment