diff options
Diffstat (limited to 'spec/frontend/releases/components/tag_field_exsting_spec.js')
-rw-r--r-- | spec/frontend/releases/components/tag_field_exsting_spec.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/spec/frontend/releases/components/tag_field_exsting_spec.js b/spec/frontend/releases/components/tag_field_exsting_spec.js new file mode 100644 index 00000000000..0a04f68bd67 --- /dev/null +++ b/spec/frontend/releases/components/tag_field_exsting_spec.js @@ -0,0 +1,78 @@ +import { GlFormInput } from '@gitlab/ui'; +import { shallowMount, mount } from '@vue/test-utils'; +import TagFieldExisting from '~/releases/components/tag_field_existing.vue'; +import createStore from '~/releases/stores'; +import createDetailModule from '~/releases/stores/modules/detail'; + +const TEST_TAG_NAME = 'test-tag-name'; +const TEST_DOCS_PATH = '/help/test/docs/path'; + +describe('releases/components/tag_field_existing', () => { + let store; + let wrapper; + + const createComponent = (mountFn = shallowMount) => { + wrapper = mountFn(TagFieldExisting, { + store, + }); + }; + + const findInput = () => wrapper.find(GlFormInput); + const findHelp = () => wrapper.find('[data-testid="tag-name-help"]'); + const findHelpLink = () => { + const link = findHelp().find('a'); + + return { + text: link.text(), + href: link.attributes('href'), + target: link.attributes('target'), + }; + }; + + beforeEach(() => { + store = createStore({ + modules: { + detail: createDetailModule({ + updateReleaseApiDocsPath: TEST_DOCS_PATH, + tagName: TEST_TAG_NAME, + }), + }, + }); + + store.state.detail.release = { + tagName: TEST_TAG_NAME, + }; + }); + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + describe('default', () => { + it('shows the tag name', () => { + createComponent(); + + expect(findInput().attributes()).toMatchObject({ + disabled: '', + value: TEST_TAG_NAME, + }); + }); + + it('shows help', () => { + createComponent(mount); + + expect(findHelp().text()).toMatchInterpolatedText( + 'Changing a Release tag is only supported via Releases API. More information', + ); + + const helpLink = findHelpLink(); + + expect(helpLink).toEqual({ + text: 'More information', + href: TEST_DOCS_PATH, + target: '_blank', + }); + }); + }); +}); |