2023-09-14 17:20:01 +08:00
|
|
|
import { validUsername, isExternal } from '@/utils/validate.js'
|
2023-09-14 17:16:49 +08:00
|
|
|
|
|
|
|
describe('Utils:validate', () => {
|
|
|
|
it('validUsername', () => {
|
|
|
|
expect(validUsername('admin')).toBe(true)
|
|
|
|
expect(validUsername('editor')).toBe(true)
|
|
|
|
expect(validUsername('xxxx')).toBe(false)
|
|
|
|
})
|
|
|
|
it('isExternal', () => {
|
|
|
|
expect(isExternal('https://github.com/PanJiaChen/vue-element-admin')).toBe(true)
|
|
|
|
expect(isExternal('http://github.com/PanJiaChen/vue-element-admin')).toBe(true)
|
|
|
|
expect(isExternal('github.com/PanJiaChen/vue-element-admin')).toBe(false)
|
|
|
|
expect(isExternal('/dashboard')).toBe(false)
|
|
|
|
expect(isExternal('./dashboard')).toBe(false)
|
|
|
|
expect(isExternal('dashboard')).toBe(false)
|
|
|
|
})
|
|
|
|
})
|