Welcome to mirror list, hosted at ThFree Co, Russian Federation.

keep_alive_component_helper_spec.js « __helpers__ « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 54d397d0997944eece8037062116df1c0196e218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { mount } from '@vue/test-utils';
import { keepAlive } from './keep_alive_component_helper';

const component = {
  template: '<div>Test Component</div>',
};

describe('keepAlive', () => {
  let wrapper;

  beforeEach(() => {
    wrapper = mount(keepAlive(component));
  });

  afterEach(() => {
    wrapper.destroy();
  });

  it('converts a component to a keep-alive component', async () => {
    const { element } = wrapper.findComponent(component);

    await wrapper.vm.deactivate();
    expect(wrapper.findComponent(component).exists()).toBe(false);

    await wrapper.vm.activate();

    // assert that when the component is destroyed and re-rendered, the
    // newly rendered component has the reference to the old component
    // (i.e. the old component was deactivated and activated)
    expect(wrapper.findComponent(component).element).toBe(element);
  });
});