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.

58 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;
2021-02-22 17:27:13 +05:30
const findFilteredSearchToken = () => wrapper.find(GlFilteredSearchToken);
2020-11-24 15:15:51 +05:30
const findAllFilteredSearchSuggestions = () => wrapper.findAll(GlFilteredSearchSuggestion);
const findAllGlIcons = () => wrapper.findAll(GlIcon);
2020-06-23 00:09:42 +05:30
const defaultProps = {
config: {
type: 'status',
icon: 'status',
title: 'Status',
unique: true,
},
value: {
data: '',
},
};
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);
});
});
});