debian-mirror-gitlab/spec/frontend/vue_shared/components/navigation_tabs_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-03-08 18:12:59 +05:30
import { GlTab } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mount } from '@vue/test-utils';
2021-03-08 18:12:59 +05:30
import NavigationTabs from '~/vue_shared/components/navigation_tabs.vue';
2018-03-17 18:26:18 +05:30
describe('navigation tabs component', () => {
2021-03-08 18:12:59 +05:30
let wrapper;
2018-03-17 18:26:18 +05:30
2021-03-08 18:12:59 +05:30
const data = [
{
name: 'All',
scope: 'all',
count: 1,
isActive: true,
},
{
name: 'Pending',
scope: 'pending',
count: 0,
isActive: false,
},
{
name: 'Running',
scope: 'running',
isActive: false,
},
];
const createComponent = () => {
wrapper = mount(NavigationTabs, {
propsData: {
tabs: data,
scope: 'pipelines',
2018-03-17 18:26:18 +05:30
},
2021-03-08 18:12:59 +05:30
});
};
2018-03-17 18:26:18 +05:30
2021-03-08 18:12:59 +05:30
beforeEach(() => {
createComponent();
2018-03-17 18:26:18 +05:30
});
it('should render tabs', () => {
2022-08-27 11:52:29 +05:30
expect(wrapper.findAllComponents(GlTab)).toHaveLength(data.length);
2018-03-17 18:26:18 +05:30
});
it('should render active tab', () => {
2021-03-08 18:12:59 +05:30
expect(wrapper.find('.js-pipelines-tab-all').classes('active')).toBe(true);
2018-03-17 18:26:18 +05:30
});
it('should render badge', () => {
2021-03-08 18:12:59 +05:30
expect(wrapper.find('.js-pipelines-tab-all').text()).toContain('1');
expect(wrapper.find('.js-pipelines-tab-pending').text()).toContain('0');
2018-03-17 18:26:18 +05:30
});
it('should not render badge', () => {
2021-03-08 18:12:59 +05:30
expect(wrapper.find('.js-pipelines-tab-running .badge').exists()).toBe(false);
2018-03-17 18:26:18 +05:30
});
2021-03-08 18:12:59 +05:30
it('should trigger onTabClick', async () => {
await wrapper.find('.js-pipelines-tab-pending').trigger('click');
2018-12-13 13:39:08 +05:30
2021-03-08 18:12:59 +05:30
expect(wrapper.emitted('onChangeTab')).toEqual([['pending']]);
2018-03-17 18:26:18 +05:30
});
});