diff options
Diffstat (limited to 'spec/frontend/issue_show/components/fields/type_spec.js')
-rw-r--r-- | spec/frontend/issue_show/components/fields/type_spec.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/frontend/issue_show/components/fields/type_spec.js b/spec/frontend/issue_show/components/fields/type_spec.js index 0c8af60d50d..fac745716d7 100644 --- a/spec/frontend/issue_show/components/fields/type_spec.js +++ b/spec/frontend/issue_show/components/fields/type_spec.js @@ -1,4 +1,4 @@ -import { GlFormGroup, GlDropdown, GlDropdownItem } from '@gitlab/ui'; +import { GlFormGroup, GlDropdown, GlDropdownItem, GlIcon } from '@gitlab/ui'; import { shallowMount, createLocalVue } from '@vue/test-utils'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; @@ -35,6 +35,9 @@ describe('Issue type field component', () => { const findTypeFromGroup = () => wrapper.findComponent(GlFormGroup); const findTypeFromDropDown = () => wrapper.findComponent(GlDropdown); const findTypeFromDropDownItems = () => wrapper.findAllComponents(GlDropdownItem); + const findTypeFromDropDownItemAt = (at) => findTypeFromDropDownItems().at(at); + const findTypeFromDropDownItemIconAt = (at) => + findTypeFromDropDownItems().at(at).findComponent(GlIcon); const createComponent = ({ data } = {}) => { fakeApollo = createMockApollo([], mockResolvers); @@ -60,6 +63,15 @@ describe('Issue type field component', () => { wrapper.destroy(); }); + it.each` + at | text | icon + ${0} | ${IssuableTypes[0].text} | ${IssuableTypes[0].icon} + ${1} | ${IssuableTypes[1].text} | ${IssuableTypes[1].icon} + `(`renders the issue type $text with an icon in the dropdown`, ({ at, text, icon }) => { + expect(findTypeFromDropDownItemIconAt(at).attributes('name')).toBe(icon); + expect(findTypeFromDropDownItemAt(at).text()).toBe(text); + }); + it('renders a form group with the correct label', () => { expect(findTypeFromGroup().attributes('label')).toBe(i18n.label); }); |