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

apiSetup.spec.ts — vue Source File

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

Entity Profile

Dependency Diagram

graph LR
  a2b23b30_76aa_ee5f_a8f9_9334ab00ccee["apiSetup.spec.ts"]
  6a13c450_be5a_326d_7e2d_c1d429be7e83["v3"]
  a2b23b30_76aa_ee5f_a8f9_9334ab00ccee --> 6a13c450_be5a_326d_7e2d_c1d429be7e83
  8a5fb776_a8f4_ce8a_8549_67af07f2e1e9["util"]
  a2b23b30_76aa_ee5f_a8f9_9334ab00ccee --> 8a5fb776_a8f4_ce8a_8549_67af07f2e1e9
  3a63aff0_8a8f_7988_aef0_ae98d03fcf43["effect"]
  a2b23b30_76aa_ee5f_a8f9_9334ab00ccee --> 3a63aff0_8a8f_7988_aef0_ae98d03fcf43
  c5601857_7faf_30c6_efca_20de90db006c["vue"]
  a2b23b30_76aa_ee5f_a8f9_9334ab00ccee --> c5601857_7faf_30c6_efca_20de90db006c
  style a2b23b30_76aa_ee5f_a8f9_9334ab00ccee fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { h, ref, reactive, isReactive, toRef, isRef } from 'v3'
import { nextTick } from 'core/util'
import { effect } from 'v3/reactivity/effect'
import Vue from 'vue'

function renderToString(comp: any) {
  const vm = new Vue(comp).$mount()
  return vm.$el.outerHTML
}

describe('api: setup context', () => {
  it('should expose return values to template render context', () => {
    const Comp = {
      setup() {
        return {
          // ref should auto-unwrap
          ref: ref('foo'),
          // object exposed as-is
          object: reactive({ msg: 'bar' }),
          // primitive value exposed as-is
          value: 'baz'
        }
      },
      render() {
        return h('div', `${this.ref} ${this.object.msg} ${this.value}`)
      }
    }
    expect(renderToString(Comp)).toMatch(`<div>foo bar baz</div>`)
  })

  it('should support returning render function', () => {
    const Comp = {
      setup() {
        return () => {
          return h('div', 'hello')
        }
      }
    }
    expect(renderToString(Comp)).toMatch(`<div>hello</div>`)
  })

  it('props', async () => {
    const count = ref(0)
    let dummy

    const Parent = {
      render: () => h(Child, { props: { count: count.value } })
    }

    const Child = {
      props: { count: Number },
      setup(props) {
        effect(() => {
          dummy = props.count
        })
        return () => h('div', props.count)
      }
    }

    const vm = new Vue(Parent).$mount()
// ... (277 more lines)

Domain

Subdomains

Functions

Dependencies

  • effect
  • util
  • v3
  • vue

Frequently Asked Questions

What does apiSetup.spec.ts do?
apiSetup.spec.ts is a source file in the vue codebase, written in typescript. It belongs to the CompilerSFC domain, TemplateTransformer subdomain.
What functions are defined in apiSetup.spec.ts?
apiSetup.spec.ts defines 1 function(s): renderToString.
What does apiSetup.spec.ts depend on?
apiSetup.spec.ts imports 4 module(s): effect, util, v3, vue.
Where is apiSetup.spec.ts in the architecture?
apiSetup.spec.ts is located at test/unit/features/v3/apiSetup.spec.ts (domain: CompilerSFC, subdomain: TemplateTransformer, directory: test/unit/features/v3).

Analyze Your Own Codebase

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

Try Supermodel Free