All files / string lowerFirst.ts

100% Statements 13/13
100% Branches 2/2
100% Functions 2/2
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                  27x             3x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x      
/**
 * format text with the first character to lower case
 *
 * @param text text to format
 * @returns text with the first character to lower case
 *
 * {@link https://lodash.com/docs#lowerFirst}
 */
export function lowerFirst(text: string) {
  return text
    .trim()
    .charAt(0)
    .toLocaleLowerCase()
    + text.slice(1)
}
 
if (import.meta.vitest) {
  const { test, expect } = import.meta.vitest
 
  test('lowerFirst', () => {
    expect(lowerFirst('useXx')).toBe('useXx')
    expect(lowerFirst('usexx')).toBe('usexx')
    expect(lowerFirst('use-xx')).toBe('use-xx')
    expect(lowerFirst('use xx')).toBe('use xx')
    expect(lowerFirst('UseXx')).toBe('useXx')
    expect(lowerFirst('use_xx')).toBe('use_xx')
    expect(lowerFirst('Use Xx')).toBe('use Xx')
    expect(lowerFirst('Use-Xx')).toBe('use-Xx')
    expect(lowerFirst('USE XX')).toBe('uSE XX')
  })
}