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.

59 lines
1.7 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';
2023-03-04 22:38:38 +05:30
import {
TOKEN_TITLE_STATUS,
TOKEN_TYPE_STATUS,
} from '~/vue_shared/components/filtered_search_bar/constants';
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: {
2023-03-04 22:38:38 +05:30
type: TOKEN_TYPE_STATUS,
2020-06-23 00:09:42 +05:30
icon: 'status',
2023-03-04 22:38:38 +05:30
title: TOKEN_TITLE_STATUS,
2020-06-23 00:09:42 +05:30
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();
});
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);
});
});
});