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

test_issue_body_spec.js « components « reports « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c13a3599fef8d13641cbbfd92cec9bbc98846421 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import Vue from 'vue';
import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { trimText } from 'helpers/text_helper';
import component from '~/reports/components/test_issue_body.vue';
import createStore from '~/reports/store';
import { issue } from '../mock_data/mock_data';

describe('Test Issue body', () => {
  let vm;
  const Component = Vue.extend(component);
  const store = createStore();

  const commonProps = {
    issue,
    status: 'failed',
  };

  afterEach(() => {
    vm.$destroy();
  });

  describe('on click', () => {
    it('calls openModal action', () => {
      vm = mountComponentWithStore(Component, {
        store,
        props: commonProps,
      });

      jest.spyOn(vm, 'openModal').mockImplementation(() => {});

      vm.$el.querySelector('button').click();

      expect(vm.openModal).toHaveBeenCalledWith({
        issue: commonProps.issue,
      });
    });
  });

  describe('is new', () => {
    beforeEach(() => {
      vm = mountComponentWithStore(Component, {
        store,
        props: { ...commonProps, isNew: true },
      });
    });

    it('renders issue name', () => {
      expect(vm.$el.textContent).toContain(commonProps.issue.name);
    });

    it('renders new badge', () => {
      expect(trimText(vm.$el.querySelector('.badge').textContent)).toEqual('New');
    });
  });

  describe('not new', () => {
    beforeEach(() => {
      vm = mountComponentWithStore(Component, {
        store,
        props: commonProps,
      });
    });

    it('renders issue name', () => {
      expect(vm.$el.textContent).toContain(commonProps.issue.name);
    });

    it('does not renders new badge', () => {
      expect(vm.$el.querySelector('.badge')).toEqual(null);
    });
  });
});