2021-03-08 18:12:59 +05:30
|
|
|
import { GlLink, GlSprintf } from '@gitlab/ui';
|
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
|
|
|
|
|
|
|
|
import ReportsModal from '~/reports/components/modal.vue';
|
2018-11-18 11:00:15 +05:30
|
|
|
import state from '~/reports/store/state';
|
2021-03-11 19:13:27 +05:30
|
|
|
import CodeBlock from '~/vue_shared/components/code_block.vue';
|
2021-03-08 18:12:59 +05:30
|
|
|
|
|
|
|
const StubbedGlModal = { template: '<div><slot></slot></div>', name: 'GlModal', props: ['title'] };
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
describe('Grouped Test Reports Modal', () => {
|
|
|
|
const modalDataStructure = state().modal.data;
|
2021-03-08 18:12:59 +05:30
|
|
|
const title = 'Test#sum when a is 1 and b is 2 returns summary';
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
// 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';
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
let wrapper;
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-03-08 18:12:59 +05:30
|
|
|
wrapper = extendedWrapper(
|
|
|
|
shallowMount(ReportsModal, {
|
|
|
|
propsData: {
|
|
|
|
title,
|
|
|
|
modalData: modalDataStructure,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
stubs: { GlModal: StubbedGlModal, GlSprintf },
|
|
|
|
}),
|
|
|
|
);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
2021-03-08 18:12:59 +05:30
|
|
|
wrapper.destroy();
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders code block', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(wrapper.find(CodeBlock).props().code).toEqual(modalDataStructure.system_output.value);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders link', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
const link = wrapper.findComponent(GlLink);
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(link.attributes().href).toEqual(modalDataStructure.class.value);
|
|
|
|
|
|
|
|
expect(link.text()).toEqual(modalDataStructure.class.value);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it('renders seconds', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(wrapper.text()).toContain(`${modalDataStructure.execution_time.value} s`);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('render title', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(wrapper.findComponent(StubbedGlModal).props().title).toEqual(title);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('re-emits hide event', () => {
|
|
|
|
wrapper.findComponent(StubbedGlModal).vm.$emit('hide');
|
|
|
|
expect(wrapper.emitted().hide).toEqual([[]]);
|
2018-11-18 11:00:15 +05:30
|
|
|
});
|
|
|
|
});
|