diff options
Diffstat (limited to 'spec/frontend/pipelines/tokens/pipeline_status_token_spec.js')
-rw-r--r-- | spec/frontend/pipelines/tokens/pipeline_status_token_spec.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/frontend/pipelines/tokens/pipeline_status_token_spec.js b/spec/frontend/pipelines/tokens/pipeline_status_token_spec.js new file mode 100644 index 00000000000..ee3694868a5 --- /dev/null +++ b/spec/frontend/pipelines/tokens/pipeline_status_token_spec.js @@ -0,0 +1,62 @@ +import { GlFilteredSearchToken, GlFilteredSearchSuggestion, GlIcon } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import PipelineStatusToken from '~/pipelines/components/tokens/pipeline_status_token.vue'; + +describe('Pipeline Status Token', () => { + let wrapper; + + const findFilteredSearchToken = () => wrapper.find(GlFilteredSearchToken); + const findAllFilteredSearchSuggestions = () => wrapper.findAll(GlFilteredSearchSuggestion); + const findAllGlIcons = () => wrapper.findAll(GlIcon); + + const stubs = { + GlFilteredSearchToken: { + template: `<div><slot name="suggestions"></slot></div>`, + }, + }; + + const defaultProps = { + config: { + type: 'status', + icon: 'status', + title: 'Status', + unique: true, + }, + value: { + data: '', + }, + }; + + const createComponent = options => { + wrapper = shallowMount(PipelineStatusToken, { + propsData: { + ...defaultProps, + }, + ...options, + }); + }; + + beforeEach(() => { + createComponent(); + }); + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + it('passes config correctly', () => { + expect(findFilteredSearchToken().props('config')).toEqual(defaultProps.config); + }); + + describe('shows statuses correctly', () => { + beforeEach(() => { + createComponent({ stubs }); + }); + + it('renders all pipeline statuses available', () => { + expect(findAllFilteredSearchSuggestions()).toHaveLength(wrapper.vm.statuses.length); + expect(findAllGlIcons()).toHaveLength(wrapper.vm.statuses.length); + }); + }); +}); |