]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(compiler-sfc):test isRelativeUrl (#1377)
authorhanmingyang <hanmingyang2009@gmail.com>
Wed, 17 Jun 2020 19:57:26 +0000 (03:57 +0800)
committerGitHub <noreply@github.com>
Wed, 17 Jun 2020 19:57:26 +0000 (15:57 -0400)
packages/compiler-sfc/__tests__/templateUtils.spec.ts [new file with mode: 0644]

diff --git a/packages/compiler-sfc/__tests__/templateUtils.spec.ts b/packages/compiler-sfc/__tests__/templateUtils.spec.ts
new file mode 100644 (file)
index 0000000..7b4490f
--- /dev/null
@@ -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)
+  })
+})