summaryrefslogtreecommitdiff
path: root/spec/javascripts/reports/components/modal_spec.js
blob: ff046e64b6e9fe15fb0795f4ab5162fccf12cbc1 (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
import Vue from 'vue';
import component from '~/reports/components/modal.vue';
import state from '~/reports/store/state';
import mountComponent from '../../helpers/vue_mount_component_helper';
import { trimText } from '../../helpers/text_helper';

describe('Grouped Test Reports Modal', () => {
  const Component = Vue.extend(component);
  const modalDataStructure = state().modal.data;

  // populate data
  modalDataStructure.execution_time.value = 0.009411;
  modalDataStructure.system_output.value = 'Failure/Error: is_expected.to eq(3)\n\n';
  modalDataStructure.class.value = 'link';

  let vm;

  beforeEach(() => {
    vm = mountComponent(Component, {
      title: 'Test#sum when a is 1 and b is 2 returns summary',
      modalData: modalDataStructure,
    });
  });

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

  it('renders code block', () => {
    expect(vm.$el.querySelector('code').textContent).toEqual(
      modalDataStructure.system_output.value,
    );
  });

  it('renders link', () => {
    expect(vm.$el.querySelector('.js-modal-link').getAttribute('href')).toEqual(
      modalDataStructure.class.value,
    );

    expect(trimText(vm.$el.querySelector('.js-modal-link').textContent)).toEqual(
      modalDataStructure.class.value,
    );
  });

  it('renders seconds', () => {
    expect(vm.$el.textContent).toContain(`${modalDataStructure.execution_time.value} s`);
  });

  it('render title', () => {
    expect(trimText(vm.$el.querySelector('.modal-title').textContent)).toEqual(
      'Test#sum when a is 1 and b is 2 returns summary',
    );
  });
});