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

65 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +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-27 19:54:05 +05:30
import SidebarAssignees from '~/sidebar/components/assignees/sidebar_assignees.vue';
2017-08-17 22:00:37 +05:30
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';
describe('sidebar assignees', () => {
2018-03-17 18:26:18 +05:30
let vm;
let mediator;
let sidebarAssigneesEl;
2019-07-07 11:18:12 +05:30
preloadFixtures('issues/open-issue.html');
2017-08-17 22:00:37 +05:30
beforeEach(() => {
2019-07-07 11:18:12 +05:30
loadFixtures('issues/open-issue.html');
2018-03-17 18:26:18 +05:30
mediator = new SidebarMediator(Mock.mediator);
spyOn(mediator, 'saveAssignees').and.callThrough();
spyOn(mediator, 'assignYourself').and.callThrough();
const SidebarAssigneeComponent = Vue.extend(SidebarAssignees);
sidebarAssigneesEl = document.querySelector('#js-vue-sidebar-assignees');
2018-12-13 13:39:08 +05:30
vm = mountComponent(
SidebarAssigneeComponent,
{
mediator,
field: sidebarAssigneesEl.dataset.field,
},
sidebarAssigneesEl,
);
2017-08-17 22:00:37 +05:30
});
afterEach(() => {
SidebarService.singleton = null;
SidebarStore.singleton = null;
SidebarMediator.singleton = null;
});
it('calls the mediator when saves the assignees', () => {
2018-03-17 18:26:18 +05:30
vm.saveAssignees();
2018-12-13 13:39:08 +05:30
2018-03-17 18:26:18 +05:30
expect(mediator.saveAssignees).toHaveBeenCalled();
2017-08-17 22:00:37 +05:30
});
it('calls the mediator when "assignSelf" method is called', () => {
2018-03-17 18:26:18 +05:30
vm.assignSelf();
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
expect(mediator.assignYourself).toHaveBeenCalled();
expect(mediator.store.assignees.length).toEqual(1);
2017-08-17 22:00:37 +05:30
});
2018-12-13 13:39:08 +05:30
it('hides assignees until fetched', done => {
2018-03-17 18:26:18 +05:30
const currentAssignee = sidebarAssigneesEl.querySelector('.value');
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(currentAssignee).toBe(null);
2018-03-17 18:26:18 +05:30
vm.store.isFetching.assignees = false;
2017-08-17 22:00:37 +05:30
Vue.nextTick(() => {
2018-03-17 18:26:18 +05:30
expect(vm.$el.querySelector('.value')).toBeVisible();
2017-08-17 22:00:37 +05:30
done();
});
});
});