All files / string lowerCase.ts

100% Statements 14/14
50% Branches 1/2
100% Functions 3/3
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                      17x     1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x      
import { splitByCase } from './splitByCase'
 
/**
 * format string to lower case
 *
 * @param text
 * @returns lower case string
 *
 * {@link https://lodash.com/docs#lowerCase}
 */
export function lowerCase(text: string) {
  return splitByCase(text).map(word => word.toLocaleLowerCase()).join(' ')
}
 
Eif (import.meta.vitest) {
  const { test, expect } = import.meta.vitest
 
  test('lowerCase', () => {
    expect(lowerCase('useXx')).toBe('use xx')
    expect(lowerCase('usexx')).toBe('usexx')
    expect(lowerCase('use-xx')).toBe('use xx')
    expect(lowerCase('use xx')).toBe('use xx')
    expect(lowerCase('UseXx')).toBe('use xx')
    expect(lowerCase('use_xx')).toBe('use xx')
    expect(lowerCase('Use Xx')).toBe('use xx')
    expect(lowerCase('Use-Xx')).toBe('use xx')
    expect(lowerCase('USE XX')).toBe('use xx')
  })
}