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

sidebar_subscriptions_spec.js « sidebar « javascripts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 88f6424423705094653c20643b303cf6f89a64ee (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
37
38
import Vue from 'vue';
import sidebarSubscriptions from '~/sidebar/components/subscriptions/sidebar_subscriptions.vue';
import SidebarMediator from '~/sidebar/sidebar_mediator';
import SidebarService from '~/sidebar/services/sidebar_service';
import SidebarStore from '~/sidebar/stores/sidebar_store';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import Mock from './mock_data';

describe('Sidebar Subscriptions', function() {
  let vm;
  let SidebarSubscriptions;

  beforeEach(() => {
    SidebarSubscriptions = Vue.extend(sidebarSubscriptions);
    // Set up the stores, services, etc
    // eslint-disable-next-line no-new
    new SidebarMediator(Mock.mediator);
  });

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

  it('calls the mediator toggleSubscription on event', () => {
    const mediator = new SidebarMediator();
    spyOn(mediator, 'toggleSubscription').and.returnValue(Promise.resolve());
    vm = mountComponent(SidebarSubscriptions, {
      mediator,
    });

    vm.onToggleSubscription();

    expect(mediator.toggleSubscription).toHaveBeenCalled();
  });
});