diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/frontend/vue_shared/components/issuable/issuable_header_warnings_spec.js | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/frontend/vue_shared/components/issuable/issuable_header_warnings_spec.js')
-rw-r--r-- | spec/frontend/vue_shared/components/issuable/issuable_header_warnings_spec.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/issuable/issuable_header_warnings_spec.js b/spec/frontend/vue_shared/components/issuable/issuable_header_warnings_spec.js new file mode 100644 index 00000000000..2f910a10bc6 --- /dev/null +++ b/spec/frontend/vue_shared/components/issuable/issuable_header_warnings_spec.js @@ -0,0 +1,73 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import Vuex from 'vuex'; +import IssuableHeaderWarnings from '~/vue_shared/components/issuable/issuable_header_warnings.vue'; +import createIssueStore from '~/notes/stores'; +import { createStore as createMrStore } from '~/mr_notes/stores'; + +const ISSUABLE_TYPE_ISSUE = 'issue'; +const ISSUABLE_TYPE_MR = 'merge request'; + +const localVue = createLocalVue(); +localVue.use(Vuex); + +describe('IssuableHeaderWarnings', () => { + let wrapper; + let store; + + const findConfidentialIcon = () => wrapper.find('[data-testid="confidential"]'); + const findLockedIcon = () => wrapper.find('[data-testid="locked"]'); + + const renderTestMessage = renders => (renders ? 'renders' : 'does not render'); + + const setLock = locked => { + store.getters.getNoteableData.discussion_locked = locked; + }; + + const setConfidential = confidential => { + store.getters.getNoteableData.confidential = confidential; + }; + + const createComponent = () => { + wrapper = shallowMount(IssuableHeaderWarnings, { store, localVue }); + }; + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + store = null; + }); + + describe.each` + issuableType + ${ISSUABLE_TYPE_ISSUE} | ${ISSUABLE_TYPE_MR} + `(`when issuableType=$issuableType`, ({ issuableType }) => { + beforeEach(() => { + store = issuableType === ISSUABLE_TYPE_ISSUE ? createIssueStore() : createMrStore(); + createComponent(); + }); + + describe.each` + lockStatus | confidentialStatus + ${true} | ${true} + ${true} | ${false} + ${false} | ${true} + ${false} | ${false} + `( + `when locked=$lockStatus and confidential=$confidentialStatus`, + ({ lockStatus, confidentialStatus }) => { + beforeEach(() => { + setLock(lockStatus); + setConfidential(confidentialStatus); + }); + + it(`${renderTestMessage(lockStatus)} the locked icon`, () => { + expect(findLockedIcon().exists()).toBe(lockStatus); + }); + + it(`${renderTestMessage(confidentialStatus)} the confidential icon`, () => { + expect(findConfidentialIcon().exists()).toBe(confidentialStatus); + }); + }, + ); + }); +}); |