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

sidebar_subscriptions_spec.js « sidebar « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d900fde7e70d9326dea66ac33fbdfae0c2ded078 (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
33
34
35
36
import { shallowMount } from '@vue/test-utils';
import SidebarSubscriptions from '~/sidebar/components/subscriptions/sidebar_subscriptions.vue';
import SidebarService from '~/sidebar/services/sidebar_service';
import SidebarMediator from '~/sidebar/sidebar_mediator';
import SidebarStore from '~/sidebar/stores/sidebar_store';
import Mock from './mock_data';

describe('Sidebar Subscriptions', () => {
  let wrapper;
  let mediator;

  beforeEach(() => {
    mediator = new SidebarMediator(Mock.mediator);
    wrapper = shallowMount(SidebarSubscriptions, {
      propsData: {
        mediator,
      },
    });
  });

  afterEach(() => {
    wrapper.destroy();
    SidebarService.singleton = null;
    SidebarStore.singleton = null;
    SidebarMediator.singleton = null;
  });

  it('calls the mediator toggleSubscription on event', () => {
    const spy = jest.spyOn(mediator, 'toggleSubscription').mockReturnValue(Promise.resolve());

    wrapper.vm.onToggleSubscription();

    expect(spy).toHaveBeenCalled();
    spy.mockRestore();
  });
});