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

components.spec.ts — vue Source File

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

File typescript VueCore 4 imports

Entity Profile

Dependency Diagram

graph LR
  0611f30c_7fbe_1eaa_6698_a9cf6ee53b85["components.spec.ts"]
  09b3d58b_2586_2d23_1760_3ec3fe090d46["test-object-option.ts"]
  0611f30c_7fbe_1eaa_6698_a9cf6ee53b85 --> 09b3d58b_2586_2d23_1760_3ec3fe090d46
  4a7600ac_90db_8739_d900_439c1c18fef7["testObjectOption"]
  0611f30c_7fbe_1eaa_6698_a9cf6ee53b85 --> 4a7600ac_90db_8739_d900_439c1c18fef7
  db9e7bef_009d_3918_6e7d_543a36a38d75["vue"]
  0611f30c_7fbe_1eaa_6698_a9cf6ee53b85 --> db9e7bef_009d_3918_6e7d_543a36a38d75
  1ec7e50f_8f20_0656_28f0_45cecc26cf74["env"]
  0611f30c_7fbe_1eaa_6698_a9cf6ee53b85 --> 1ec7e50f_8f20_0656_28f0_45cecc26cf74
  style 0611f30c_7fbe_1eaa_6698_a9cf6ee53b85 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import Vue from 'vue'
import { UA } from 'core/util/env'
import testObjectOption from '../../../helpers/test-object-option'

describe('Options components', () => {
  testObjectOption('components')

  it('should accept plain object', () => {
    const vm = new Vue({
      template: '<test></test>',
      components: {
        test: {
          template: '<div>hi</div>'
        }
      }
    }).$mount()
    expect(vm.$el.tagName).toBe('DIV')
    expect(vm.$el.textContent).toBe('hi')
  })

  it('should accept extended constructor', () => {
    const Test = Vue.extend({
      template: '<div>hi</div>'
    })
    const vm = new Vue({
      template: '<test></test>',
      components: {
        test: Test
      }
    }).$mount()
    expect(vm.$el.tagName).toBe('DIV')
    expect(vm.$el.textContent).toBe('hi')
  })

  it('should accept camelCase', () => {
    const myComp = {
      template: '<div>hi</div>'
    }
    const vm = new Vue({
      template: '<my-comp></my-comp>',
      components: {
        myComp
      }
    }).$mount()
    expect(vm.$el.tagName).toBe('DIV')
    expect(vm.$el.textContent).toBe('hi')
  })

  it('should accept PascalCase', () => {
    const MyComp = {
      template: '<div>hi</div>'
    }
    const vm = new Vue({
      template: '<my-comp></my-comp>',
      components: {
        MyComp
      }
    }).$mount()
    expect(vm.$el.tagName).toBe('DIV')
    expect(vm.$el.textContent).toBe('hi')
  })

  it('should warn native HTML elements', () => {
    new Vue({
      components: {
        div: { template: '<div></div>' }
      }
    })
    expect(
      'Do not use built-in or reserved HTML elements as component'
    ).toHaveBeenWarned()
  })

  it('should warn built-in elements', () => {
    new Vue({
      components: {
        component: { template: '<div></div>' }
      }
    })
    expect(
      'Do not use built-in or reserved HTML elements as component'
    ).toHaveBeenWarned()
  })

  // the HTMLUnknownElement check doesn't work in Android 4.2
  // but since it doesn't support custom elements nor will any dev use it
  // as their primary debugging browser, it doesn't really matter.
  if (!(UA && /android 4\.2/.test(UA))) {
    it('warn non-existent', () => {
      new Vue({
        template: '<test></test>'
      }).$mount()
      expect('Unknown custom element: <test>').toHaveBeenWarned()
    })
  }
})

Domain

Frequently Asked Questions

What does components.spec.ts do?
components.spec.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain.
What does components.spec.ts depend on?
components.spec.ts imports 4 module(s): env, test-object-option.ts, testObjectOption, vue.
Where is components.spec.ts in the architecture?
components.spec.ts is located at test/unit/features/options/components.spec.ts (domain: VueCore, 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