Browse Source

test: 100% vue packages coverage (#1371)

蜗牛老湿 5 năm trước cách đây
mục cha
commit
79686e90e2
2 tập tin đã thay đổi với 21 bổ sung0 xóa
  1. 20 0
      packages/vue/__tests__/index.spec.ts
  2. 1 0
      packages/vue/src/index.ts

+ 20 - 0
packages/vue/__tests__/index.spec.ts

@@ -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()
+  })
 })

+ 1 - 0
packages/vue/src/index.ts

@@ -56,6 +56,7 @@ function compileToFunction(
               )
             warn(codeFrame ? `${message}\n${codeFrame}` : message)
           } else {
+            /* istanbul ignore next */
             throw err
           }
         }