debian-mirror-gitlab/spec/frontend/ide/components/activity_bar_spec.js

73 lines
2 KiB
JavaScript
Raw Normal View History

2018-10-15 14:42:47 +05:30
import Vue from 'vue';
2020-10-24 23:57:45 +05:30
import { createStore } from '~/ide/stores';
2020-03-13 15:44:24 +05:30
import { leftSidebarViews } from '~/ide/constants';
2018-10-15 14:42:47 +05:30
import ActivityBar from '~/ide/components/activity_bar.vue';
import { createComponentWithStore } from '../../helpers/vue_mount_component_helper';
describe('IDE activity bar', () => {
const Component = Vue.extend(ActivityBar);
let vm;
2020-10-24 23:57:45 +05:30
let store;
2018-10-15 14:42:47 +05:30
beforeEach(() => {
2020-10-24 23:57:45 +05:30
store = createStore();
2018-10-15 14:42:47 +05:30
Vue.set(store.state.projects, 'abcproject', {
web_url: 'testing',
});
Vue.set(store.state, 'currentProjectId', 'abcproject');
vm = createComponentWithStore(Component, store);
});
afterEach(() => {
vm.$destroy();
});
describe('updateActivityBarView', () => {
beforeEach(() => {
2020-05-24 23:13:21 +05:30
jest.spyOn(vm, 'updateActivityBarView').mockImplementation(() => {});
2018-10-15 14:42:47 +05:30
vm.$mount();
});
it('calls updateActivityBarView with edit value on click', () => {
vm.$el.querySelector('.js-ide-edit-mode').click();
2020-03-13 15:44:24 +05:30
expect(vm.updateActivityBarView).toHaveBeenCalledWith(leftSidebarViews.edit.name);
2018-10-15 14:42:47 +05:30
});
it('calls updateActivityBarView with commit value on click', () => {
vm.$el.querySelector('.js-ide-commit-mode').click();
2020-03-13 15:44:24 +05:30
expect(vm.updateActivityBarView).toHaveBeenCalledWith(leftSidebarViews.commit.name);
2018-10-15 14:42:47 +05:30
});
it('calls updateActivityBarView with review value on click', () => {
vm.$el.querySelector('.js-ide-review-mode').click();
2020-03-13 15:44:24 +05:30
expect(vm.updateActivityBarView).toHaveBeenCalledWith(leftSidebarViews.review.name);
2018-10-15 14:42:47 +05:30
});
});
describe('active item', () => {
beforeEach(() => {
vm.$mount();
});
it('sets edit item active', () => {
expect(vm.$el.querySelector('.js-ide-edit-mode').classList).toContain('active');
});
it('sets commit item active', done => {
2020-03-13 15:44:24 +05:30
vm.$store.state.currentActivityView = leftSidebarViews.commit.name;
2018-10-15 14:42:47 +05:30
vm.$nextTick(() => {
expect(vm.$el.querySelector('.js-ide-commit-mode').classList).toContain('active');
done();
});
});
});
});