debian-mirror-gitlab/spec/javascripts/sidebar/sidebar_subscriptions_spec.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
2020-01-01 13:55:28 +05:30
import mountComponent from 'spec/helpers/vue_mount_component_helper';
2018-03-17 18:26:18 +05:30
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 Mock from './mock_data';
2018-12-13 13:39:08 +05:30
describe('Sidebar Subscriptions', function() {
2018-03-17 18:26:18 +05:30
let vm;
let SidebarSubscriptions;
beforeEach(() => {
SidebarSubscriptions = Vue.extend(sidebarSubscriptions);
2018-12-05 23:21:45 +05:30
// Set up the stores, services, etc
2018-03-17 18:26:18 +05:30
// 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,
});
2018-10-15 14:42:47 +05:30
vm.onToggleSubscription();
2018-03-17 18:26:18 +05:30
expect(mediator.toggleSubscription).toHaveBeenCalled();
});
});