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

on.spec.ts — vue Source File

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

File typescript 3 imports

Entity Profile

Dependency Diagram

graph LR
  7c40468a_15e9_7dee_f483_c5d296c39fa9["on.spec.ts"]
  c5601857_7faf_30c6_efca_20de90db006c["vue"]
  7c40468a_15e9_7dee_f483_c5d296c39fa9 --> c5601857_7faf_30c6_efca_20de90db006c
  b1eb2bb2_8774_a6f3_1b5c_854efafa7ee6["env"]
  7c40468a_15e9_7dee_f483_c5d296c39fa9 --> b1eb2bb2_8774_a6f3_1b5c_854efafa7ee6
  7f32ec3a_99ad_9ce7_e7fe_dddb639f1e61["vitest"]
  7c40468a_15e9_7dee_f483_c5d296c39fa9 --> 7f32ec3a_99ad_9ce7_e7fe_dddb639f1e61
  style 7c40468a_15e9_7dee_f483_c5d296c39fa9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import Vue from 'vue'
import { supportsPassive } from 'core/util/env'
import { SpyInstanceFn } from 'vitest'

describe('Directive v-on', () => {
  let vm, spy: SpyInstanceFn, el: HTMLElement

  beforeEach(() => {
    vm = null
    spy = vi.fn()
    el = document.createElement('div')
    document.body.appendChild(el)
  })

  afterEach(() => {
    if (vm) {
      document.body.removeChild(vm.$el)
    }
  })

  it('should bind event to a method', () => {
    vm = new Vue({
      el,
      template: '<div v-on:click="foo"></div>',
      methods: { foo: spy }
    })
    triggerEvent(vm.$el, 'click')
    expect(spy.mock.calls.length).toBe(1)

    const args = spy.mock.calls
    const event = (args[0] && args[0][0]) || {}
    expect(event.type).toBe('click')
  })

  it('should bind event to an inline statement', () => {
    vm = new Vue({
      el,
      template: '<div v-on:click="foo(1,2,3,$event)"></div>',
      methods: { foo: spy }
    })
    triggerEvent(vm.$el, 'click')
    expect(spy.mock.calls.length).toBe(1)

    const args = spy.mock.calls
    const firstArgs = args[0]
    expect(firstArgs.length).toBe(4)
    expect(firstArgs[0]).toBe(1)
    expect(firstArgs[1]).toBe(2)
    expect(firstArgs[2]).toBe(3)
    expect(firstArgs[3].type).toBe('click')
  })

  it('should support inline function expression', () => {
    const spy = vi.fn()
    vm = new Vue({
      el,
      template: `<div class="test" @click="function (e) { log(e.target.className) }"></div>`,
      methods: {
        log: spy
      }
// ... (1152 more lines)

Dependencies

  • env
  • vitest
  • vue

Frequently Asked Questions

What does on.spec.ts do?
on.spec.ts is a source file in the vue codebase, written in typescript.
What does on.spec.ts depend on?
on.spec.ts imports 3 module(s): env, vitest, vue.
Where is on.spec.ts in the architecture?
on.spec.ts is located at test/unit/features/directives/on.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