modal_spec.js 1.56 KB
Newer Older
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
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/vue_component_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', () => {
Mike Greiling's avatar
Mike Greiling committed
30 31 32
    expect(vm.$el.querySelector('code').textContent).toEqual(
      modalDataStructure.system_output.value,
    );
33 34 35
  });

  it('renders link', () => {
Mike Greiling's avatar
Mike Greiling committed
36 37 38
    expect(vm.$el.querySelector('.js-modal-link').getAttribute('href')).toEqual(
      modalDataStructure.class.value,
    );
Mike Greiling's avatar
Mike Greiling committed
39

Mike Greiling's avatar
Mike Greiling committed
40 41 42
    expect(trimText(vm.$el.querySelector('.js-modal-link').textContent)).toEqual(
      modalDataStructure.class.value,
    );
43 44 45 46 47 48 49
  });

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

  it('render title', () => {
Mike Greiling's avatar
Mike Greiling committed
50 51 52
    expect(trimText(vm.$el.querySelector('.modal-title').textContent)).toEqual(
      'Test#sum when a is 1 and b is 2 returns summary',
    );
53 54
  });
});