Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/issue_show/components/issuable_header_warnings_spec.js')
-rw-r--r--spec/frontend/issue_show/components/issuable_header_warnings_spec.js79
1 files changed, 79 insertions, 0 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);
+ });
+ });
+});