2021-08-17 14:10:35 -04:00
|
|
|
import { GlFilteredSearchToken, GlFilteredSearchSuggestion } from '@gitlab/ui';
|
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2021-09-14 11:12:05 -04:00
|
|
|
import { PIPELINE_SOURCES } from 'ee_else_ce/pipelines/components/pipelines_list/tokens/constants';
|
2021-08-17 14:10:35 -04:00
|
|
|
import { stubComponent } from 'helpers/stub_component';
|
|
|
|
import PipelineSourceToken from '~/pipelines/components/pipelines_list/tokens/pipeline_source_token.vue';
|
|
|
|
|
|
|
|
describe('Pipeline Source Token', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2022-09-12 11:14:03 -04:00
|
|
|
const findFilteredSearchToken = () => wrapper.findComponent(GlFilteredSearchToken);
|
2022-09-13 14:12:21 -04:00
|
|
|
const findAllFilteredSearchSuggestions = () =>
|
|
|
|
wrapper.findAllComponents(GlFilteredSearchSuggestion);
|
2021-08-17 14:10:35 -04:00
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
config: {
|
|
|
|
type: 'source',
|
|
|
|
icon: 'trigger-source',
|
|
|
|
title: 'Source',
|
|
|
|
unique: true,
|
|
|
|
},
|
|
|
|
value: {
|
|
|
|
data: '',
|
|
|
|
},
|
2022-04-22 11:09:52 -04:00
|
|
|
cursorPosition: 'start',
|
2021-08-17 14:10:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const createComponent = () => {
|
|
|
|
wrapper = shallowMount(PipelineSourceToken, {
|
|
|
|
propsData: {
|
|
|
|
...defaultProps,
|
|
|
|
},
|
|
|
|
stubs: {
|
|
|
|
GlFilteredSearchToken: stubComponent(GlFilteredSearchToken, {
|
|
|
|
template: `<div><slot name="suggestions"></slot></div>`,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('passes config correctly', () => {
|
|
|
|
expect(findFilteredSearchToken().props('config')).toEqual(defaultProps.config);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('shows sources correctly', () => {
|
|
|
|
it('renders all pipeline sources available', () => {
|
2021-09-14 11:12:05 -04:00
|
|
|
expect(findAllFilteredSearchSuggestions()).toHaveLength(PIPELINE_SOURCES.length);
|
2021-08-17 14:10:35 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|