Home / File/ text.spec.ts — vue Source File

text.spec.ts — vue Source File

Architecture documentation for text.spec.ts, a typescript file in the vue codebase. 1 imports, 0 dependents.

File typescript 1 imports

Entity Profile

Dependency Diagram

graph LR
  8672e93b_b03c_f8fe_e95f_7f2649ae38cb["text.spec.ts"]
  db9e7bef_009d_3918_6e7d_543a36a38d75["vue"]
  8672e93b_b03c_f8fe_e95f_7f2649ae38cb --> db9e7bef_009d_3918_6e7d_543a36a38d75
  style 8672e93b_b03c_f8fe_e95f_7f2649ae38cb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import Vue from 'vue'

describe('Directive v-text', () => {
  it('should render text', () => {
    const vm = new Vue({
      template: '<div v-text="a"></div>',
      data: { a: 'hello' }
    }).$mount()
    expect(vm.$el.innerHTML).toBe('hello')
  })

  it('should encode html entities', () => {
    const vm = new Vue({
      template: '<div v-text="a"></div>',
      data: { a: '<foo>' }
    }).$mount()
    expect(vm.$el.innerHTML).toBe('&lt;foo&gt;')
  })

  it('should support all value types', done => {
    const vm = new Vue({
      template: '<div v-text="a"></div>',
      data: { a: false }
    }).$mount()
    waitForUpdate(() => {
      expect(vm.$el.innerHTML).toBe('false')
      vm.a = []
    })
      .then(() => {
        expect(vm.$el.innerHTML).toBe('[]')
        vm.a = {}
      })
      .then(() => {
        expect(vm.$el.innerHTML).toBe('{}')
        vm.a = {
          toString() {
            return 'foo'
          }
        }
      })
      .then(() => {
        expect(vm.$el.innerHTML).toBe('foo')
        vm.a = {
          toJSON() {
            return { foo: 'bar' }
          }
        }
      })
      .then(() => {
        expect(vm.$el.innerHTML).toBe('{\n  "foo": "bar"\n}')
        vm.a = 123
      })
      .then(() => {
        expect(vm.$el.innerHTML).toBe('123')
        vm.a = 0
      })
      .then(() => {
        expect(vm.$el.innerHTML).toBe('0')
        vm.a = ' '
      })
      .then(() => {
        expect(vm.$el.innerHTML).toBe(' ')
        vm.a = '    '
      })
      .then(() => {
        expect(vm.$el.innerHTML).toBe('    ')
        vm.a = null
      })
      .then(() => {
        expect(vm.$el.innerHTML).toBe('')
        vm.a = undefined
      })
      .then(() => {
        expect(vm.$el.innerHTML).toBe('')
      })
      .then(done)
  })
})

Dependencies

  • vue

Frequently Asked Questions

What does text.spec.ts do?
text.spec.ts is a source file in the vue codebase, written in typescript.
What does text.spec.ts depend on?
text.spec.ts imports 1 module(s): vue.
Where is text.spec.ts in the architecture?
text.spec.ts is located at test/unit/features/directives/text.spec.ts (directory: test/unit/features/directives).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free