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

diff_comment_cell_spec.js « components « diffs « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b636a1785931776755b3d3f4e06796e64095314b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { shallowMount } from '@vue/test-utils';
import DiffCommentCell from '~/diffs/components/diff_comment_cell.vue';
import DiffDiscussionReply from '~/diffs/components/diff_discussion_reply.vue';
import DiffDiscussions from '~/diffs/components/diff_discussions.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);
  });
});