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
  feb5bedf_47d0_a5f0_0cce_733cbe044581["on.spec.ts"]
  db9e7bef_009d_3918_6e7d_543a36a38d75["vue"]
  feb5bedf_47d0_a5f0_0cce_733cbe044581 --> db9e7bef_009d_3918_6e7d_543a36a38d75
  1ec7e50f_8f20_0656_28f0_45cecc26cf74["env"]
  feb5bedf_47d0_a5f0_0cce_733cbe044581 --> 1ec7e50f_8f20_0656_28f0_45cecc26cf74
  c7fbd7f1_e080_f33c_4dc6_acfb8c6719db["vitest"]
  feb5bedf_47d0_a5f0_0cce_733cbe044581 --> c7fbd7f1_e080_f33c_4dc6_acfb8c6719db
  style feb5bedf_47d0_a5f0_0cce_733cbe044581 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