import { describe, test, expect } from 'vitest' import { capitalizeFirstLetter, sortObjectByKey } from './utils' describe('sortObjectByKey', () => { test('sorts object keys alphabetically', () => { const obj = { b: 2, a: 1, c: 3 } const sortedObj = sortObjectByKey(obj) expect(sortedObj).toEqual({ a: 1, b: 2, c: 3 }) }) test('handles empty object', () => { const obj = {} const sortedObj = sortObjectByKey(obj) expect(sortedObj).toEqual({}) }) test('keeps object keys in original order if already sorted', () => { const obj = { a: 1, b: 2, c: 3 } const sortedObj = sortObjectByKey(obj) expect(sortedObj).toEqual({ a: 1, b: 2, c: 3 }) }) test('sorts object keys in reverse alphabetical order', () => { const obj = { z: 1, b: 2, a: 3 } const sortedObj = sortObjectByKey(obj) expect(sortedObj).toEqual({ a: 3, b: 2, z: 1 }) }) test('sorts object keys in natural order', () => { const sortedObj1 = sortObjectByKey({ 'ScandicRed-100': 1, 'ScandicRed-20': 1, 'ScandicRed-40': 1, 'ScandicRed-10': 1, 'Grey-80': 1, }) expect(Object.keys(sortedObj1)).toEqual([ 'Grey-80', 'ScandicRed-10', 'ScandicRed-20', 'ScandicRed-40', 'ScandicRed-100', ]) }) }) describe('capitalizeFirstLetter function', () => { test('capitalizes the first letter of a string', () => { expect(capitalizeFirstLetter('hello')).toBe('Hello') }) test('does not change an empty string', () => { expect(capitalizeFirstLetter('')).toBe('') }) test('does not change a string already starting with an uppercase letter', () => { expect(capitalizeFirstLetter('World')).toBe('World') }) })