2019-09-20 12:56:02 +08:00
|
|
|
import { createApp } from '../src'
|
|
|
|
|
|
|
|
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`)
|
|
|
|
})
|
2019-10-12 03:09:37 +08:00
|
|
|
|
|
|
|
it('should correctly normalize class with on-the-fly template compilation', () => {
|
|
|
|
const container = document.createElement('div')
|
|
|
|
const App = {
|
|
|
|
template: `<div :class="{ test: demoValue, test2: !demoValue }"></div>`,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
demoValue: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createApp().mount(App, container)
|
|
|
|
const classes = container.firstElementChild!.classList
|
|
|
|
expect(classes.contains('test')).toBe(true)
|
|
|
|
expect(classes.contains('test2')).toBe(false)
|
|
|
|
})
|
2019-10-16 05:30:47 +08:00
|
|
|
|
|
|
|
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>')
|
|
|
|
})
|