test: 100% vue packages coverage (#1371)

This commit is contained in:
蜗牛老湿 2020-06-15 21:29:58 +08:00 committed by GitHub
parent ee60a0967f
commit 79686e90e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View 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()
})
})

View File

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