Home / File/ create-component.spec.ts — vue Source File

create-component.spec.ts — vue Source File

Architecture documentation for create-component.spec.ts, a typescript file in the vue codebase. 3 imports, 0 dependents.

File typescript 3 imports

Entity Profile

Dependency Diagram

graph LR
  ceed7cbc_ae1b_67cf_1655_c07fb4a21810["create-component.spec.ts"]
  db9e7bef_009d_3918_6e7d_543a36a38d75["vue"]
  ceed7cbc_ae1b_67cf_1655_c07fb4a21810 --> db9e7bef_009d_3918_6e7d_543a36a38d75
  800bf47d_e926_ea5e_e853_f265c156d637["create-component"]
  ceed7cbc_ae1b_67cf_1655_c07fb4a21810 --> 800bf47d_e926_ea5e_e853_f265c156d637
  b30af6be_9313_348e_8cd5_66005796592e["render"]
  ceed7cbc_ae1b_67cf_1655_c07fb4a21810 --> b30af6be_9313_348e_8cd5_66005796592e
  style ceed7cbc_ae1b_67cf_1655_c07fb4a21810 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import Vue from 'vue'
import { createComponent } from 'core/vdom/create-component'
import { setCurrentRenderingInstance } from 'core/instance/render'

describe('create-component', () => {
  let vm
  beforeEach(() => {
    vm = new Vue({
      template: '<p>{{msg}}</p>',
      data() {
        return { msg: 'hello, my children' }
      }
    }).$mount()
    return new Promise(r => Vue.nextTick(r))
  })

  it('create a component basically', () => {
    const child = {
      name: 'child',
      props: ['msg'],
      render() {}
    }
    const data = {
      props: { msg: 'hello world' },
      attrs: { id: 1 },
      staticAttrs: { class: 'foo' },
      on: { notify: 'onNotify' }
    }
    const vnode = createComponent(child, data, vm, vm)
    expect(vnode.tag).toMatch(/vue-component-[0-9]+-child/)
    expect(vnode.data.attrs).toEqual({ id: 1 })
    expect(vnode.data.staticAttrs).toEqual({ class: 'foo' })
    expect(vnode.componentOptions.propsData).toEqual({ msg: 'hello world' })
    expect(vnode.componentOptions.listeners).toEqual({ notify: 'onNotify' })
    expect(vnode.children).toBeUndefined()
    expect(vnode.text).toBeUndefined()
    expect(vnode.elm).toBeUndefined()
    expect(vnode.ns).toBeUndefined()
    expect(vnode.context).toEqual(vm)
  })

  it('create a component when resolved with async loading', done => {
    let vnode = null
    const data = {
      props: {},
      staticAttrs: { class: 'foo' }
    }
    vi.spyOn(vm, '$forceUpdate')
    function async(resolve, reject) {
      setTimeout(() => {
        resolve({
          name: 'child',
          props: ['msg']
        })
        Vue.nextTick(loaded)
      }, 0)
    }
    function go() {
      setCurrentRenderingInstance(vm)
      vnode = createComponent(async, data, vm, vm)
// ... (96 more lines)

Dependencies

  • create-component
  • render
  • vue

Frequently Asked Questions

What does create-component.spec.ts do?
create-component.spec.ts is a source file in the vue codebase, written in typescript.
What does create-component.spec.ts depend on?
create-component.spec.ts imports 3 module(s): create-component, render, vue.
Where is create-component.spec.ts in the architecture?
create-component.spec.ts is located at test/unit/modules/vdom/create-component.spec.ts (directory: test/unit/modules/vdom).

Analyze Your Own Codebase

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

Try Supermodel Free