fix: fix an error when the validLowerCase and validUpperCase function have no params
This commit is contained in:
parent
1bc2e5c198
commit
3e4fbb1b0c
|
@ -33,6 +33,7 @@ export function validURL(url) {
|
|||
* @returns {Boolean}
|
||||
*/
|
||||
export function validLowerCase(str) {
|
||||
if (str === undefined || str === null) return false
|
||||
const reg = /^[a-z]+$/
|
||||
return reg.test(str)
|
||||
}
|
||||
|
@ -42,6 +43,7 @@ export function validLowerCase(str) {
|
|||
* @returns {Boolean}
|
||||
*/
|
||||
export function validUpperCase(str) {
|
||||
if (str === undefined || str === null) return false
|
||||
const reg = /^[A-Z]+$/
|
||||
return reg.test(str)
|
||||
}
|
||||
|
|
|
@ -14,11 +14,13 @@ describe('Utils:validate', () => {
|
|||
expect(validLowerCase('abc')).toBe(true)
|
||||
expect(validLowerCase('Abc')).toBe(false)
|
||||
expect(validLowerCase('123abc')).toBe(false)
|
||||
expect(validLowerCase()).toBe(false)
|
||||
})
|
||||
it('validUpperCase', () => {
|
||||
expect(validUpperCase('ABC')).toBe(true)
|
||||
expect(validUpperCase('Abc')).toBe(false)
|
||||
expect(validUpperCase('123ABC')).toBe(false)
|
||||
expect(validUpperCase()).toBe(false)
|
||||
})
|
||||
it('validAlphabets', () => {
|
||||
expect(validAlphabets('ABC')).toBe(true)
|
||||
|
|
Loading…
Reference in New Issue