debian-mirror-gitlab/spec/javascripts/reports/components/modal_spec.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-11-18 11:00:15 +05:30
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';
2019-09-04 21:01:54 +05:30
import { trimText } from '../../helpers/text_helper';
2018-11-18 11:00:15 +05:30
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', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('code').textContent).toEqual(
modalDataStructure.system_output.value,
);
2018-11-18 11:00:15 +05:30
});
it('renders link', () => {
2018-12-13 13:39:08 +05:30
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,
);
2018-11-18 11:00:15 +05:30
});
2020-03-13 15:44:24 +05:30
it('renders seconds', () => {
expect(vm.$el.textContent).toContain(`${modalDataStructure.execution_time.value} s`);
2018-11-18 11:00:15 +05:30
});
it('render title', () => {
2018-12-13 13:39:08 +05:30
expect(trimText(vm.$el.querySelector('.modal-title').textContent)).toEqual(
'Test#sum when a is 1 and b is 2 returns summary',
);
2018-11-18 11:00:15 +05:30
});
});