2017-10-31 16:15:03 +00:00
|
|
|
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';
|
2018-02-26 19:43:34 +00:00
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2017-10-31 16:15:03 +00:00
|
|
|
import Mock from './mock_data';
|
|
|
|
|
2018-10-17 07:13:26 +00:00
|
|
|
describe('Sidebar Subscriptions', function() {
|
2017-10-31 16:15:03 +00:00
|
|
|
let vm;
|
|
|
|
let SidebarSubscriptions;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
SidebarSubscriptions = Vue.extend(sidebarSubscriptions);
|
2018-09-17 09:17:33 +00:00
|
|
|
// Set up the stores, services, etc
|
2017-10-31 16:15:03 +00:00
|
|
|
// 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', () => {
|
2017-12-07 17:37:33 +00:00
|
|
|
const mediator = new SidebarMediator();
|
|
|
|
spyOn(mediator, 'toggleSubscription').and.returnValue(Promise.resolve());
|
|
|
|
vm = mountComponent(SidebarSubscriptions, {
|
|
|
|
mediator,
|
|
|
|
});
|
2017-10-31 16:15:03 +00:00
|
|
|
|
2018-05-03 07:32:04 +00:00
|
|
|
vm.onToggleSubscription();
|
2017-10-31 16:15:03 +00:00
|
|
|
|
2017-12-07 17:37:33 +00:00
|
|
|
expect(mediator.toggleSubscription).toHaveBeenCalled();
|
2017-10-31 16:15:03 +00:00
|
|
|
});
|
|
|
|
});
|