import { transformSnakeCase, uuid } from './utils'; describe('uuid', () => { it('should generate a random uuid each time', () => { const uniqueId = uuid(); expect(typeof uniqueId).toBe('string'); expect(uniqueId).toMatch(/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/); const uniqueId2 = uuid(); expect(uniqueId).not.toBe(uniqueId2); }); }); describe('transformSnakeCase', () => { it.each([ ['data_entry', 'dataEntry'], ['user_input', 'userInput'], ['file_path', 'filePath'], ['image_size', 'imageSize'], ['color_code', 'colorCode'], ['table_row', 'tableRow'], ['page_number', 'pageNumber'], ['search_query', 'searchQuery'], ['last_update', 'lastUpdate'], ['item_list', 'itemList'], ])('should convert %s to camelCase "%s"', (input, expected) => { expect(transformSnakeCase(input)).toBe(expected); }); it.each([ 'dataEntry', 'userInput', 'filePath', 'imageSize', 'colorCode', 'tableRow', 'pageNumber', 'searchQuery', 'lastUpdate', 'itemList', ])('should maintain camelCase formatting for camelCase strings passed in', (input) => { expect(transformSnakeCase(input)).toBe(input); }); });