debian-mirror-gitlab/spec/frontend/pipelines/tokens/pipeline_status_token_spec.js

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

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-06-23 00:09:42 +05:30
import { GlFilteredSearchToken, GlFilteredSearchSuggestion, GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
2021-02-22 17:27:13 +05:30
import { stubComponent } from 'helpers/stub_component';
2020-07-28 23:09:34 +05:30
import PipelineStatusToken from '~/pipelines/components/pipelines_list/tokens/pipeline_status_token.vue';
2020-06-23 00:09:42 +05:30
describe('Pipeline Status Token', () => {
let wrapper;
2022-10-11 01:57:18 +05:30
const findFilteredSearchToken = () => wrapper.findComponent(GlFilteredSearchToken);
const findAllFilteredSearchSuggestions = () =>
wrapper.findAllComponents(GlFilteredSearchSuggestion);
const findAllGlIcons = () => wrapper.findAllComponents(GlIcon);
2020-11-24 15:15:51 +05:30
2020-06-23 00:09:42 +05:30
const defaultProps = {
config: {
type: 'status',
icon: 'status',
title: 'Status',
unique: true,
},
value: {
data: '',
},
2022-07-16 23:28:13 +05:30
cursorPosition: 'start',
2020-06-23 00:09:42 +05:30
};
2020-11-24 15:15:51 +05:30
const createComponent = () => {
2020-06-23 00:09:42 +05:30
wrapper = shallowMount(PipelineStatusToken, {
propsData: {
...defaultProps,
},
2021-02-22 17:27:13 +05:30
stubs: {
GlFilteredSearchToken: stubComponent(GlFilteredSearchToken, {
template: `<div><slot name="suggestions"></slot></div>`,
}),
},
2020-06-23 00:09:42 +05:30
});
};
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('passes config correctly', () => {
expect(findFilteredSearchToken().props('config')).toEqual(defaultProps.config);
});
describe('shows statuses correctly', () => {
it('renders all pipeline statuses available', () => {
expect(findAllFilteredSearchSuggestions()).toHaveLength(wrapper.vm.statuses.length);
expect(findAllGlIcons()).toHaveLength(wrapper.vm.statuses.length);
});
});
});