fe-drone-ci/tests/unit/utils/validate.spec.js

29 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2019-03-11 06:41:20 +00:00
import { validUsername, validURL, validLowerCase, validUpperCase, validAlphabets } from '@/utils/validate.js'
2018-10-29 07:29:54 +00:00
describe('Utils:validate', () => {
it('validUsername', () => {
expect(validUsername('admin')).toBe(true)
expect(validUsername('editor')).toBe(true)
expect(validUsername('xxxx')).toBe(false)
})
2019-03-11 06:41:20 +00:00
it('validURL', () => {
expect(validURL('https://github.com/PanJiaChen/vue-element-admin')).toBe(true)
expect(validURL('http://github.com/PanJiaChen/vue-element-admin')).toBe(true)
expect(validURL('github.com/PanJiaChen/vue-element-admin')).toBe(false)
2018-10-29 07:29:54 +00:00
})
2019-03-11 06:41:20 +00:00
it('validLowerCase', () => {
expect(validLowerCase('abc')).toBe(true)
expect(validLowerCase('Abc')).toBe(false)
expect(validLowerCase('123abc')).toBe(false)
2018-10-29 07:29:54 +00:00
})
2019-03-11 06:41:20 +00:00
it('validUpperCase', () => {
expect(validUpperCase('ABC')).toBe(true)
expect(validUpperCase('Abc')).toBe(false)
expect(validUpperCase('123ABC')).toBe(false)
2018-10-29 07:29:54 +00:00
})
2019-03-11 06:41:20 +00:00
it('validAlphabets', () => {
expect(validAlphabets('ABC')).toBe(true)
expect(validAlphabets('Abc')).toBe(true)
expect(validAlphabets('123aBC')).toBe(false)
2018-10-29 07:29:54 +00:00
})
})