diff options
Diffstat (limited to 'spec/frontend/ci/runner/components/runner_tags_spec.js')
-rw-r--r-- | spec/frontend/ci/runner/components/runner_tags_spec.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/frontend/ci/runner/components/runner_tags_spec.js b/spec/frontend/ci/runner/components/runner_tags_spec.js new file mode 100644 index 00000000000..96bec00302b --- /dev/null +++ b/spec/frontend/ci/runner/components/runner_tags_spec.js @@ -0,0 +1,54 @@ +import { GlBadge } from '@gitlab/ui'; +import { mount } from '@vue/test-utils'; +import RunnerTags from '~/ci/runner/components/runner_tags.vue'; + +describe('RunnerTags', () => { + let wrapper; + + const findBadge = () => wrapper.findComponent(GlBadge); + const findBadgesAt = (i = 0) => wrapper.findAllComponents(GlBadge).at(i); + + const createComponent = ({ props = {} } = {}) => { + wrapper = mount(RunnerTags, { + propsData: { + tagList: ['tag1', 'tag2'], + ...props, + }, + }); + }; + + beforeEach(() => { + createComponent(); + }); + + afterEach(() => { + wrapper.destroy(); + }); + + it('Displays tags text', () => { + expect(wrapper.text()).toMatchInterpolatedText('tag1 tag2'); + + expect(findBadgesAt(0).text()).toBe('tag1'); + expect(findBadgesAt(1).text()).toBe('tag2'); + }); + + it('Displays tags with correct style', () => { + expect(findBadge().props('size')).toBe('sm'); + }); + + it('Displays tags with md size', () => { + createComponent({ + props: { size: 'md' }, + }); + + expect(findBadge().props('size')).toBe('md'); + }); + + it('Is empty when there are no tags', () => { + createComponent({ + props: { tagList: null }, + }); + + expect(wrapper.html()).toEqual(''); + }); +}); |