1 Star 4 Fork 0

李金文/vue-next学习

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.spec.ts 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
李金文 提交于 2019-12-08 11:17 +08:00 . first commit
import { createApp } from '../src'
import { mockWarn } from '@vue/runtime-test'
describe('compiler + runtime integration', () => {
mockWarn()
it('should support on-the-fly template compilation', () => {
const container = document.createElement('div')
const App = {
template: `{{ count }}`,
data() {
return {
count: 0
}
}
}
createApp().mount(App, container)
expect(container.innerHTML).toBe(`0`)
})
it('should warn template compilation errors with codeframe', () => {
const container = document.createElement('div')
const App = {
template: `<div v-if>`
}
createApp().mount(App, container)
expect(
`Template compilation error: End tag was not found`
).toHaveBeenWarned()
expect(`v-if/v-else-if is missing expression`).toHaveBeenWarned()
expect(
`
1 | <div v-if>
| ^^^^`.trim()
).toHaveBeenWarned()
})
it('should support custom element', () => {
const app = createApp()
const container = document.createElement('div')
const App = {
template: '<custom></custom>'
}
app.config.isCustomElement = tag => tag === 'custom'
app.mount(App, container)
expect(container.innerHTML).toBe('<custom></custom>')
})
it('should support using element innerHTML as template', () => {
const app = createApp()
const container = document.createElement('div')
container.innerHTML = '{{msg}}'
const App = {
data: {
msg: 'hello'
}
}
app.mount(App, container)
expect(container.innerHTML).toBe('hello')
})
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kennana/vue_next_learning.git
git@gitee.com:kennana/vue_next_learning.git
kennana
vue_next_learning
vue-next学习
master

搜索帮助