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

commit_comments_button_spec.js « components « commit « projects « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 873270c5be145601b14b2ba9569ddd78434ef53c (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
import { shallowMount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import CommitCommentsButton from '~/projects/commit/components/commit_comments_button.vue';

describe('CommitCommentsButton', () => {
  let wrapper;

  const createComponent = (props = {}) => {
    wrapper = extendedWrapper(
      shallowMount(CommitCommentsButton, {
        propsData: {
          commentsCount: 1,
          ...props,
        },
      }),
    );
  };

  const tooltip = () => wrapper.findByTestId('comment-button-wrapper');

  describe('Comment Button', () => {
    it('has proper tooltip and button attributes for 1 comment', () => {
      createComponent();

      expect(tooltip().attributes('title')).toBe('1 comment on this commit');
      expect(tooltip().text()).toBe('1');
    });

    it('has proper tooltip and button attributes for multiple comments', () => {
      createComponent({ commentsCount: 2 });

      expect(tooltip().attributes('title')).toBe('2 comments on this commit');
      expect(tooltip().text()).toBe('2');
    });

    it('does not show when there are no comments', () => {
      createComponent({ commentsCount: 0 });

      expect(tooltip().exists()).toBe(false);
    });
  });
});