2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
2018-03-27 19:54:05 +05:30
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2020-01-01 13:55:28 +05:30
|
|
|
import navigationTabs from '~/vue_shared/components/navigation_tabs.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe('navigation tabs component', () => {
|
|
|
|
let vm;
|
|
|
|
let Component;
|
|
|
|
let data;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
data = [
|
|
|
|
{
|
|
|
|
name: 'All',
|
|
|
|
scope: 'all',
|
|
|
|
count: 1,
|
|
|
|
isActive: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Pending',
|
|
|
|
scope: 'pending',
|
|
|
|
count: 0,
|
|
|
|
isActive: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Running',
|
|
|
|
scope: 'running',
|
|
|
|
isActive: false,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
Component = Vue.extend(navigationTabs);
|
|
|
|
vm = mountComponent(Component, { tabs: data, scope: 'pipelines' });
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render tabs', () => {
|
|
|
|
expect(vm.$el.querySelectorAll('li').length).toEqual(data.length);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render active tab', () => {
|
|
|
|
expect(vm.$el.querySelector('.active .js-pipelines-tab-all')).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render badge', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-pipelines-tab-all .badge').textContent.trim()).toEqual('1');
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(vm.$el.querySelector('.js-pipelines-tab-pending .badge').textContent.trim()).toEqual(
|
|
|
|
'0',
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render badge', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-pipelines-tab-running .badge')).toEqual(null);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should trigger onTabClick', () => {
|
|
|
|
spyOn(vm, '$emit');
|
|
|
|
vm.$el.querySelector('.js-pipelines-tab-pending').click();
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$emit).toHaveBeenCalledWith('onChangeTab', 'pending');
|
|
|
|
});
|
|
|
|
});
|