summaryrefslogtreecommitdiff
path: root/spec/frontend/diffs/components/diff_comment_cell_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/diffs/components/diff_comment_cell_spec.js')
-rw-r--r--spec/frontend/diffs/components/diff_comment_cell_spec.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/frontend/diffs/components/diff_comment_cell_spec.js b/spec/frontend/diffs/components/diff_comment_cell_spec.js
new file mode 100644
index 00000000000..d6b68fc52d7
--- /dev/null
+++ b/spec/frontend/diffs/components/diff_comment_cell_spec.js
@@ -0,0 +1,43 @@
+import { shallowMount } from '@vue/test-utils';
+import DiffCommentCell from '~/diffs/components/diff_comment_cell.vue';
+import DiffDiscussions from '~/diffs/components/diff_discussions.vue';
+import DiffDiscussionReply from '~/diffs/components/diff_discussion_reply.vue';
+
+describe('DiffCommentCell', () => {
+ const createWrapper = (props = {}) => {
+ const { renderDiscussion, ...otherProps } = props;
+ const line = {
+ discussions: [],
+ renderDiscussion,
+ };
+ const diffFileHash = 'abc';
+
+ return shallowMount(DiffCommentCell, {
+ propsData: { line, diffFileHash, ...otherProps },
+ });
+ };
+
+ it('renders discussions if line has discussions', () => {
+ const wrapper = createWrapper({ renderDiscussion: true });
+
+ expect(wrapper.find(DiffDiscussions).exists()).toBe(true);
+ });
+
+ it('does not render discussions if line has no discussions', () => {
+ const wrapper = createWrapper();
+
+ expect(wrapper.find(DiffDiscussions).exists()).toBe(false);
+ });
+
+ it('renders discussion reply if line has no draft', () => {
+ const wrapper = createWrapper();
+
+ expect(wrapper.find(DiffDiscussionReply).exists()).toBe(true);
+ });
+
+ it('does not render discussion reply if line has draft', () => {
+ const wrapper = createWrapper({ hasDraft: true });
+
+ expect(wrapper.find(DiffDiscussionReply).exists()).toBe(false);
+ });
+});