templateUtils.spec.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {
  2. isRelativeUrl,
  3. isExternalUrl
  4. } from '../../compiler-sfc/src/templateUtils'
  5. describe('compiler sfc:templateUtils isRelativeUrl', () => {
  6. test('should return true when The first character of the string path is .', () => {
  7. const url = './**.vue'
  8. const result = isRelativeUrl(url)
  9. expect(result).toBe(true)
  10. })
  11. test('should return true when The first character of the string path is ~', () => {
  12. const url = '~/xx.vue'
  13. const result = isRelativeUrl(url)
  14. expect(result).toBe(true)
  15. })
  16. test('should return true when The first character of the string path is @', () => {
  17. const url = '@/xx.vue'
  18. const result = isRelativeUrl(url)
  19. expect(result).toBe(true)
  20. })
  21. })
  22. describe('compiler sfc:templateUtils isExternalUrl', () => {
  23. test('should return true when String starts with http://', () => {
  24. const url = 'http://vuejs.org/'
  25. const result = isExternalUrl(url)
  26. expect(result).toBe(true)
  27. })
  28. test('should return true when String starts with https://', () => {
  29. const url = 'https://vuejs.org/'
  30. const result = isExternalUrl(url)
  31. expect(result).toBe(true)
  32. })
  33. })