merge: Upgrade Lower function (#894)

* docs: update the js doc

* pref: Optimize algo via regex

ignore the useless traverse in best case via regex and String.prototype.replace

* test: add some new test cases

* fix: styled with standard

* refactor: remove useless variable
This commit is contained in:
Fahim Faisaal
2022-02-19 17:38:55 +06:00
committed by GitHub
parent 29a3ab73bc
commit 041918d7b7
2 changed files with 21 additions and 16 deletions

View File

@ -1,9 +1,19 @@
import { lower } from '../Lower'
describe('Lower', () => {
it('return uppercase strings', () => {
expect(lower('hello')).toBe('hello')
describe('Testing the Lower function', () => {
it('Test 1: Check by invalid type', () => {
expect(() => lower(345)).toThrowError()
expect(() => lower(true)).toThrowError()
expect(() => lower(null)).toThrowError()
})
it('Test 2: Check by uppercase string', () => {
expect(lower('WORLD')).toBe('world')
expect(lower('hello_WORLD')).toBe('hello_world')
expect(lower('Hello_WORLD')).toBe('hello_world')
})
it('Test 3: Check by lowercase string', () => {
expect(lower('hello')).toBe('hello')
expect(lower('hello_world')).toBe('hello_world')
})
})