diff options
Diffstat (limited to 'spec/frontend/issue_show/components')
-rw-r--r-- | spec/frontend/issue_show/components/issuable_header_warnings_spec.js | 79 | ||||
-rw-r--r-- | spec/frontend/issue_show/components/pinned_links_spec.js | 15 |
2 files changed, 87 insertions, 7 deletions
diff --git a/spec/frontend/issue_show/components/issuable_header_warnings_spec.js b/spec/frontend/issue_show/components/issuable_header_warnings_spec.js new file mode 100644 index 00000000000..5a166812d84 --- /dev/null +++ b/spec/frontend/issue_show/components/issuable_header_warnings_spec.js @@ -0,0 +1,79 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import Vuex from 'vuex'; +import IssuableHeaderWarnings from '~/issue_show/components/issuable_header_warnings.vue'; +import createStore from '~/notes/stores'; + +const localVue = createLocalVue(); +localVue.use(Vuex); + +describe('IssuableHeaderWarnings', () => { + let wrapper; + let store; + + const findConfidential = () => wrapper.find('[data-testid="confidential"]'); + const findLocked = () => wrapper.find('[data-testid="locked"]'); + const confidentialIconName = () => findConfidential().attributes('name'); + const lockedIconName = () => findLocked().attributes('name'); + + const createComponent = () => { + wrapper = shallowMount(IssuableHeaderWarnings, { store, localVue }); + }; + + beforeEach(() => { + store = createStore(); + }); + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + store = null; + }); + + describe('when confidential is on', () => { + beforeEach(() => { + store.state.noteableData.confidential = true; + + createComponent(); + }); + + it('renders the confidential icon', () => { + expect(confidentialIconName()).toBe('eye-slash'); + }); + }); + + describe('when confidential is off', () => { + beforeEach(() => { + store.state.noteableData.confidential = false; + + createComponent(); + }); + + it('does not find the component', () => { + expect(findConfidential().exists()).toBe(false); + }); + }); + + describe('when discussion locked is on', () => { + beforeEach(() => { + store.state.noteableData.discussion_locked = true; + + createComponent(); + }); + + it('renders the locked icon', () => { + expect(lockedIconName()).toBe('lock'); + }); + }); + + describe('when discussion locked is off', () => { + beforeEach(() => { + store.state.noteableData.discussion_locked = false; + + createComponent(); + }); + + it('does not find the component', () => { + expect(findLocked().exists()).toBe(false); + }); + }); +}); diff --git a/spec/frontend/issue_show/components/pinned_links_spec.js b/spec/frontend/issue_show/components/pinned_links_spec.js index 007ad4c9a1b..bb67feee601 100644 --- a/spec/frontend/issue_show/components/pinned_links_spec.js +++ b/spec/frontend/issue_show/components/pinned_links_spec.js @@ -1,6 +1,7 @@ import { shallowMount } from '@vue/test-utils'; -import { GlLink } from '@gitlab/ui'; +import { GlButton } from '@gitlab/ui'; import PinnedLinks from '~/issue_show/components/pinned_links.vue'; +import { STATUS_PAGE_PUBLISHED, JOIN_ZOOM_MEETING } from '~/issue_show/constants'; const plainZoomUrl = 'https://zoom.us/j/123456789'; const plainStatusUrl = 'https://status.com'; @@ -8,7 +9,7 @@ const plainStatusUrl = 'https://status.com'; describe('PinnedLinks', () => { let wrapper; - const findLinks = () => wrapper.findAll(GlLink); + const findButtons = () => wrapper.findAll(GlButton); const createComponent = props => { wrapper = shallowMount(PinnedLinks, { @@ -26,10 +27,10 @@ describe('PinnedLinks', () => { }); expect( - findLinks() + findButtons() .at(0) .text(), - ).toBe('Join Zoom meeting'); + ).toBe(JOIN_ZOOM_MEETING); }); it('displays Status link', () => { @@ -38,10 +39,10 @@ describe('PinnedLinks', () => { }); expect( - findLinks() + findButtons() .at(0) .text(), - ).toBe('Published on status page'); + ).toBe(STATUS_PAGE_PUBLISHED); }); it('does not render if there are no links', () => { @@ -50,6 +51,6 @@ describe('PinnedLinks', () => { publishedIncidentUrl: '', }); - expect(wrapper.find(GlLink).exists()).toBe(false); + expect(findButtons()).toHaveLength(0); }); }); |