test(compiler-sfc):test isRelativeUrl (#1377)
This commit is contained in:
parent
e68209bfdb
commit
bf5aba8f19
38
packages/compiler-sfc/__tests__/templateUtils.spec.ts
Normal file
38
packages/compiler-sfc/__tests__/templateUtils.spec.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import {
|
||||||
|
isRelativeUrl,
|
||||||
|
isExternalUrl
|
||||||
|
} from '../../compiler-sfc/src/templateUtils'
|
||||||
|
|
||||||
|
describe('compiler sfc:templateUtils isRelativeUrl', () => {
|
||||||
|
test('should return true when The first character of the string path is .', () => {
|
||||||
|
const url = './**.vue'
|
||||||
|
const result = isRelativeUrl(url)
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('should return true when The first character of the string path is ~', () => {
|
||||||
|
const url = '~/xx.vue'
|
||||||
|
const result = isRelativeUrl(url)
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('should return true when The first character of the string path is @', () => {
|
||||||
|
const url = '@/xx.vue'
|
||||||
|
const result = isRelativeUrl(url)
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('compiler sfc:templateUtils isExternalUrl', () => {
|
||||||
|
test('should return true when String starts with http://', () => {
|
||||||
|
const url = 'http://vuejs.org/'
|
||||||
|
const result = isExternalUrl(url)
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('should return true when String starts with https://', () => {
|
||||||
|
const url = 'https://vuejs.org/'
|
||||||
|
const result = isExternalUrl(url)
|
||||||
|
expect(result).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user