2018-10-15 14:42:47 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import store from '~/ide/stores';
|
|
|
|
import ideStatusBar from '~/ide/components/ide_status_bar.vue';
|
2018-12-05 23:21:45 +05:30
|
|
|
import { rightSidebarViews } from '~/ide/constants';
|
2018-10-15 14:42:47 +05:30
|
|
|
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
|
|
|
|
import { resetStore } from '../helpers';
|
|
|
|
import { projectData } from '../mock_data';
|
|
|
|
|
|
|
|
describe('ideStatusBar', () => {
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
const Component = Vue.extend(ideStatusBar);
|
|
|
|
|
|
|
|
store.state.currentProjectId = 'abcproject';
|
|
|
|
store.state.projects.abcproject = projectData;
|
2018-11-18 11:00:15 +05:30
|
|
|
store.state.currentBranchId = 'master';
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
vm = createComponentWithStore(Component, store).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
|
|
|
|
resetStore(vm.$store);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the statusbar', () => {
|
|
|
|
expect(vm.$el.className).toBe('ide-status-bar');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('mounted', () => {
|
|
|
|
it('triggers a setInterval', () => {
|
|
|
|
expect(vm.intervalId).not.toBe(null);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('commitAgeUpdate', () => {
|
|
|
|
beforeEach(function() {
|
|
|
|
jasmine.clock().install();
|
|
|
|
spyOn(vm, 'commitAgeUpdate').and.callFake(() => {});
|
|
|
|
vm.startTimer();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
jasmine.clock().uninstall();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('gets called every second', () => {
|
|
|
|
expect(vm.commitAgeUpdate).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
jasmine.clock().tick(1100);
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(vm.commitAgeUpdate.calls.count()).toEqual(1);
|
|
|
|
|
|
|
|
jasmine.clock().tick(1000);
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(vm.commitAgeUpdate.calls.count()).toEqual(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getCommitPath', () => {
|
|
|
|
it('returns the path to the commit details', () => {
|
|
|
|
expect(vm.getCommitPath('abc123de')).toBe('/commit/abc123de');
|
|
|
|
});
|
|
|
|
});
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
describe('pipeline status', () => {
|
|
|
|
it('opens right sidebar on clicking icon', done => {
|
2018-12-05 23:21:45 +05:30
|
|
|
spyOn(vm, 'openRightPane');
|
2018-11-18 11:00:15 +05:30
|
|
|
Vue.set(vm.$store.state.pipelines, 'latestPipeline', {
|
|
|
|
details: {
|
|
|
|
status: {
|
|
|
|
text: 'success',
|
|
|
|
details_path: 'test',
|
|
|
|
icon: 'status_success',
|
|
|
|
},
|
|
|
|
},
|
2019-03-02 22:35:43 +05:30
|
|
|
commit: {
|
|
|
|
author_gravatar_url: 'www',
|
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
vm.$nextTick()
|
2018-11-18 11:00:15 +05:30
|
|
|
.then(() => {
|
|
|
|
vm.$el.querySelector('.ide-status-pipeline button').click();
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
expect(vm.openRightPane).toHaveBeenCalledWith(rightSidebarViews.pipelines);
|
2018-11-18 11:00:15 +05:30
|
|
|
})
|
|
|
|
.then(done)
|
|
|
|
.catch(done.fail);
|
|
|
|
});
|
|
|
|
});
|
2018-10-15 14:42:47 +05:30
|
|
|
});
|