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/diffs/components/diff_discussion_reply_spec.js')
-rw-r--r--spec/frontend/diffs/components/diff_discussion_reply_spec.js36
1 files changed, 33 insertions, 3 deletions
diff --git a/spec/frontend/diffs/components/diff_discussion_reply_spec.js b/spec/frontend/diffs/components/diff_discussion_reply_spec.js
index 5ccd2002462..bf4a1a1c1f7 100644
--- a/spec/frontend/diffs/components/diff_discussion_reply_spec.js
+++ b/spec/frontend/diffs/components/diff_discussion_reply_spec.js
@@ -1,10 +1,12 @@
import { shallowMount } from '@vue/test-utils';
+import { GlButton } from '@gitlab/ui';
import Vue from 'vue';
import Vuex from 'vuex';
import DiffDiscussionReply from '~/diffs/components/diff_discussion_reply.vue';
-import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue';
import NoteSignedOutWidget from '~/notes/components/note_signed_out_widget.vue';
+import { START_THREAD } from '~/diffs/i18n';
+
Vue.use(Vuex);
describe('DiffDiscussionReply', () => {
@@ -58,14 +60,42 @@ describe('DiffDiscussionReply', () => {
expect(wrapper.find('#test-form').exists()).toBe(true);
});
- it('should render a reply placeholder if there is no form', () => {
+ it('should render a reply placeholder button if there is no form', () => {
createComponent({
renderReplyPlaceholder: true,
hasForm: false,
});
- expect(wrapper.findComponent(ReplyPlaceholder).exists()).toBe(true);
+ expect(wrapper.findComponent(GlButton).text()).toBe(START_THREAD);
});
+
+ it.each`
+ userCanReply | hasForm | renderReplyPlaceholder | showButton
+ ${false} | ${false} | ${false} | ${false}
+ ${true} | ${false} | ${false} | ${false}
+ ${true} | ${true} | ${false} | ${false}
+ ${true} | ${true} | ${true} | ${false}
+ ${true} | ${false} | ${true} | ${true}
+ ${false} | ${false} | ${true} | ${false}
+ `(
+ 'reply button existence is `$showButton` when userCanReply is `$userCanReply`, hasForm is `$hasForm` and renderReplyPlaceholder is `$renderReplyPlaceholder`',
+ ({ userCanReply, hasForm, renderReplyPlaceholder, showButton }) => {
+ getters = {
+ userCanReply: () => userCanReply,
+ };
+
+ store = new Vuex.Store({
+ getters,
+ });
+
+ createComponent({
+ renderReplyPlaceholder,
+ hasForm,
+ });
+
+ expect(wrapper.findComponent(GlButton).exists()).toBe(showButton);
+ },
+ );
});
it('renders a signed out widget when user is not logged in', () => {