Home / File/ component-keep-alive.spec.ts — vue Source File

component-keep-alive.spec.ts — vue Source File

Architecture documentation for component-keep-alive.spec.ts, a typescript file in the vue codebase. 1 imports, 0 dependents.

File typescript 1 imports

Entity Profile

Dependency Diagram

graph LR
  f2a4eb5a_e08c_a134_a2cc_0f783856934f["component-keep-alive.spec.ts"]
  db9e7bef_009d_3918_6e7d_543a36a38d75["vue"]
  f2a4eb5a_e08c_a134_a2cc_0f783856934f --> db9e7bef_009d_3918_6e7d_543a36a38d75
  style f2a4eb5a_e08c_a134_a2cc_0f783856934f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import Vue from 'vue'

describe('Component keep-alive', () => {
  let components, one, two, el
  beforeEach(() => {
    one = {
      template: '<div>one</div>',
      created: vi.fn(),
      mounted: vi.fn(),
      activated: vi.fn(),
      deactivated: vi.fn(),
      destroyed: vi.fn()
    }
    two = {
      template: '<div>two</div>',
      created: vi.fn(),
      mounted: vi.fn(),
      activated: vi.fn(),
      deactivated: vi.fn(),
      destroyed: vi.fn()
    }
    components = {
      one,
      two
    }
    el = document.createElement('div')
    document.body.appendChild(el)
  })

  function assertHookCalls(component, callCounts) {
    expect([
      component.created.mock.calls.length,
      component.mounted.mock.calls.length,
      component.activated.mock.calls.length,
      component.deactivated.mock.calls.length,
      component.destroyed.mock.calls.length
    ]).toEqual(callCounts)
  }

  it('should work', done => {
    const vm = new Vue({
      template: `
        <div v-if="ok">
          <keep-alive>
            <component :is="view"></component>
          </keep-alive>
        </div>
      `,
      data: {
        view: 'one',
        ok: true
      },
      components
    }).$mount()
    expect(vm.$el.textContent).toBe('one')
    assertHookCalls(one, [1, 1, 1, 0, 0])
    assertHookCalls(two, [0, 0, 0, 0, 0])
    vm.view = 'two'
    waitForUpdate(() => {
      expect(vm.$el.textContent).toBe('two')
// ... (774 more lines)

Dependencies

  • vue

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free