2017-08-29 12:20:58 +00:00
|
|
|
import Vue from 'vue';
|
2017-11-23 12:04:03 +00:00
|
|
|
import navigationTabs from '~/vue_shared/components/navigation_tabs.vue';
|
2018-02-26 19:43:34 +00:00
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2017-08-29 12:20:58 +00:00
|
|
|
|
2017-11-23 12:04:03 +00:00
|
|
|
describe('navigation tabs component', () => {
|
2017-08-29 12:20:58 +00:00
|
|
|
let vm;
|
|
|
|
let Component;
|
|
|
|
let data;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2017-11-14 15:35:29 +00:00
|
|
|
data = [
|
|
|
|
{
|
|
|
|
name: 'All',
|
|
|
|
scope: 'all',
|
|
|
|
count: 1,
|
|
|
|
isActive: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Pending',
|
|
|
|
scope: 'pending',
|
|
|
|
count: 0,
|
|
|
|
isActive: false,
|
2017-08-29 12:20:58 +00:00
|
|
|
},
|
2017-11-14 15:35:29 +00:00
|
|
|
{
|
|
|
|
name: 'Running',
|
|
|
|
scope: 'running',
|
|
|
|
isActive: false,
|
2017-08-29 12:20:58 +00:00
|
|
|
},
|
2017-11-14 15:35:29 +00:00
|
|
|
];
|
2017-08-29 12:20:58 +00:00
|
|
|
|
|
|
|
Component = Vue.extend(navigationTabs);
|
2017-11-23 12:04:03 +00:00
|
|
|
vm = mountComponent(Component, { tabs: data, scope: 'pipelines' });
|
2017-08-29 12:20:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
2017-11-14 15:35:29 +00:00
|
|
|
it('should render tabs', () => {
|
|
|
|
expect(vm.$el.querySelectorAll('li').length).toEqual(data.length);
|
2017-08-29 12:20:58 +00:00
|
|
|
});
|
|
|
|
|
2017-11-14 15:35:29 +00:00
|
|
|
it('should render active tab', () => {
|
|
|
|
expect(vm.$el.querySelector('.active .js-pipelines-tab-all')).toBeDefined();
|
2017-08-29 12:20:58 +00:00
|
|
|
});
|
|
|
|
|
2017-11-14 15:35:29 +00:00
|
|
|
it('should render badge', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-pipelines-tab-all .badge').textContent.trim()).toEqual('1');
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(vm.$el.querySelector('.js-pipelines-tab-pending .badge').textContent.trim()).toEqual(
|
|
|
|
'0',
|
|
|
|
);
|
2017-11-14 15:35:29 +00:00
|
|
|
});
|
2017-08-29 12:20:58 +00:00
|
|
|
|
2017-11-14 15:35:29 +00:00
|
|
|
it('should not render badge', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-pipelines-tab-running .badge')).toEqual(null);
|
2017-08-29 12:20:58 +00:00
|
|
|
});
|
2017-11-23 12:04:03 +00:00
|
|
|
|
|
|
|
it('should trigger onTabClick', () => {
|
|
|
|
spyOn(vm, '$emit');
|
|
|
|
vm.$el.querySelector('.js-pipelines-tab-pending').click();
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2017-11-23 12:04:03 +00:00
|
|
|
expect(vm.$emit).toHaveBeenCalledWith('onChangeTab', 'pending');
|
|
|
|
});
|
2017-08-29 12:20:58 +00:00
|
|
|
});
|