]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: 100% vue packages coverage (#1371)
author蜗牛老湿 <shengxinjing@users.noreply.github.com>
Mon, 15 Jun 2020 13:29:58 +0000 (21:29 +0800)
committerGitHub <noreply@github.com>
Mon, 15 Jun 2020 13:29:58 +0000 (09:29 -0400)
packages/vue/__tests__/index.spec.ts
packages/vue/src/index.ts

index eb38d9d1868a61b1cf21b7d7036536a557f3f77e..5a71706be91abb736d88a1588e1d749b30cefdd5 100644 (file)
@@ -98,4 +98,24 @@ describe('compiler + runtime integration', () => {
     app.mount(container)
     expect(container.innerHTML).toBe('hello')
   })
+
+  it('should warn when template is not avaiable', () => {
+    const app = createApp({
+      template: {}
+    })
+    const container = document.createElement('div')
+    app.mount(container)
+    expect('[Vue warn]: invalid template option:').toHaveBeenWarned()
+  })
+
+  it('should warn when template is is not found', () => {
+    const app = createApp({
+      template: '#not-exist-id'
+    })
+    const container = document.createElement('div')
+    app.mount(container)
+    expect(
+      '[Vue warn]: Template element not found or is empty: #not-exist-id'
+    ).toHaveBeenWarned()
+  })
 })
index db3c45dd14a60512bd0cb8be139d2c61e8f07d7a..d6a472a2046ee08e7eb891922028302b9c44ee5d 100644 (file)
@@ -56,6 +56,7 @@ function compileToFunction(
               )
             warn(codeFrame ? `${message}\n${codeFrame}` : message)
           } else {
+            /* istanbul ignore next */
             throw err
           }
         }