template.spec.ts — vue Source File
Architecture documentation for template.spec.ts, a typescript file in the vue codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d6e3fa99_d840_5fde_dbd4_46678414d4c2["template.spec.ts"] db9e7bef_009d_3918_6e7d_543a36a38d75["vue"] d6e3fa99_d840_5fde_dbd4_46678414d4c2 --> db9e7bef_009d_3918_6e7d_543a36a38d75 style d6e3fa99_d840_5fde_dbd4_46678414d4c2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import Vue from 'vue'
describe('Options template', () => {
let el
beforeEach(() => {
el = document.createElement('script')
el.type = 'x-template'
el.id = 'app'
el.innerHTML = '<p>{{message}}</p>'
document.body.appendChild(el)
})
afterEach(() => {
document.body.removeChild(el)
})
it('basic usage', () => {
const vm = new Vue({
template: '<div>{{message}}</div>',
data: { message: 'hello world' }
}).$mount()
expect(vm.$el.tagName).toBe('DIV')
expect(vm.$el.textContent).toBe(vm.message)
})
it('id reference', () => {
const vm = new Vue({
template: '#app',
data: { message: 'hello world' }
}).$mount()
expect(vm.$el.tagName).toBe('P')
expect(vm.$el.textContent).toBe(vm.message)
})
it('DOM element', () => {
const elm = document.createElement('p')
elm.innerHTML = '<p>{{message}}</p>'
const vm = new Vue({
template: elm,
data: { message: 'hello world' }
}).$mount()
expect(vm.$el.tagName).toBe('P')
expect(vm.$el.textContent).toBe(vm.message)
})
it('invalid template', () => {
new Vue({
template: Vue,
data: { message: 'hello world' }
}).$mount()
expect('invalid template option').toHaveBeenWarned()
})
it('warn error in generated function', () => {
new Vue({
template:
'<div v-if="!@"><span>{{ a"" }}</span><span>{{ do + 1 }}</span></div>'
}).$mount()
expect('Error compiling template').toHaveBeenWarned()
expect('Raw expression: v-if="!@"').toHaveBeenWarned()
expect('Raw expression: {{ a"" }}').toHaveBeenWarned()
expect(
'avoid using JavaScript keyword as property name: "do"'
).toHaveBeenWarned()
})
it('should not warn $ prefixed keywords', () => {
new Vue({
template: `<div @click="$delete(foo, 'bar')"></div>`
}).$mount()
expect(
'avoid using JavaScript keyword as property name'
).not.toHaveBeenWarned()
})
it('warn error in generated function (v-for)', () => {
new Vue({
template: '<div><div v-for="(1, 2) in a----"></div></div>'
}).$mount()
expect('Error compiling template').toHaveBeenWarned()
expect('invalid v-for alias "1"').toHaveBeenWarned()
expect('invalid v-for iterator "2"').toHaveBeenWarned()
expect('Raw expression: v-for="(1, 2) in a----"').toHaveBeenWarned()
})
it('warn error in generated function (v-on)', () => {
new Vue({
template: `<div @click="delete('Delete')"></div>`,
methods: { delete: function () {} }
}).$mount()
expect('Error compiling template').toHaveBeenWarned()
expect(
`avoid using JavaScript unary operator as property name: "delete()" in expression @click="delete('Delete')"`
).toHaveBeenWarned()
})
})
Dependencies
- vue
Source
Frequently Asked Questions
What does template.spec.ts do?
template.spec.ts is a source file in the vue codebase, written in typescript.
What does template.spec.ts depend on?
template.spec.ts imports 1 module(s): vue.
Where is template.spec.ts in the architecture?
template.spec.ts is located at test/unit/features/options/template.spec.ts (directory: test/unit/features/options).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free