summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/issue/issue_warning_spec.js
diff options
context:
space:
mode:
authorMartin Hobert <info@dosh.dk>2019-04-25 16:33:40 +0200
committerMartin Hobert <info@dosh.dk>2019-04-25 16:33:40 +0200
commit396dbbd415e12d469f6aecaac4144e74fb8e7ec0 (patch)
tree9f928ff68217a427c6c0f1908f68a0552838d773 /spec/frontend/vue_shared/components/issue/issue_warning_spec.js
parent66ff5f3dc6c19ea382192897395acfbd4adbd0c2 (diff)
downloadgitlab-ce-396dbbd415e12d469f6aecaac4144e74fb8e7ec0.tar.gz
refactor(issue): Refactored issue tests from Karma to Jest
re #58827 Added changelog Added sync false, and removed unneeded destroyers
Diffstat (limited to 'spec/frontend/vue_shared/components/issue/issue_warning_spec.js')
-rw-r--r--spec/frontend/vue_shared/components/issue/issue_warning_spec.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/issue/issue_warning_spec.js b/spec/frontend/vue_shared/components/issue/issue_warning_spec.js
new file mode 100644
index 00000000000..4a8de5fc4f1
--- /dev/null
+++ b/spec/frontend/vue_shared/components/issue/issue_warning_spec.js
@@ -0,0 +1,59 @@
+import Vue from 'vue';
+import issueWarning from '~/vue_shared/components/issue/issue_warning.vue';
+import mountComponent from 'helpers/vue_mount_component_helper';
+
+const IssueWarning = Vue.extend(issueWarning);
+
+function formatWarning(string) {
+ // Replace newlines with a space then replace multiple spaces with one space
+ return string
+ .trim()
+ .replace(/\n/g, ' ')
+ .replace(/\s\s+/g, ' ');
+}
+
+describe('Issue Warning Component', () => {
+ describe('isLocked', () => {
+ it('should render locked issue warning information', () => {
+ const vm = mountComponent(IssueWarning, {
+ isLocked: true,
+ });
+
+ expect(
+ vm.$el.querySelector('.icon use').getAttributeNS('http://www.w3.org/1999/xlink', 'href'),
+ ).toMatch(/lock$/);
+ expect(formatWarning(vm.$el.querySelector('span').textContent)).toEqual(
+ 'This issue is locked. Only project members can comment.',
+ );
+ });
+ });
+
+ describe('isConfidential', () => {
+ it('should render confidential issue warning information', () => {
+ const vm = mountComponent(IssueWarning, {
+ isConfidential: true,
+ });
+
+ expect(
+ vm.$el.querySelector('.icon use').getAttributeNS('http://www.w3.org/1999/xlink', 'href'),
+ ).toMatch(/eye-slash$/);
+ expect(formatWarning(vm.$el.querySelector('span').textContent)).toEqual(
+ 'This is a confidential issue. Your comment will not be visible to the public.',
+ );
+ });
+ });
+
+ describe('isLocked and isConfidential', () => {
+ it('should render locked and confidential issue warning information', () => {
+ const vm = mountComponent(IssueWarning, {
+ isLocked: true,
+ isConfidential: true,
+ });
+
+ expect(vm.$el.querySelector('.icon')).toBeFalsy();
+ expect(formatWarning(vm.$el.querySelector('span').textContent)).toEqual(
+ "This issue is confidential and locked. People without permission will never get a notification and won't be able to comment.",
+ );
+ });
+ });
+});