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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
import Vuex from 'vuex';
import { mount, createLocalVue } from '@vue/test-utils';
import { getJSONFixture } from 'helpers/fixtures';
import SummaryTable from '~/pipelines/components/test_reports/test_summary_table.vue';
import * as getters from '~/pipelines/stores/test_reports/getters';
const localVue = createLocalVue();
localVue.use(Vuex);
describe('Test reports summary table', () => {
let wrapper;
let store;
const testReports = getJSONFixture('pipelines/test_report.json');
const allSuitesRows = () => wrapper.findAll('.js-suite-row');
const noSuitesToShow = () => wrapper.find('.js-no-tests-suites');
const defaultProps = {
testReports,
};
const createComponent = (reports = null) => {
store = new Vuex.Store({
state: {
testReports: reports || testReports,
},
getters,
});
wrapper = mount(SummaryTable, {
propsData: defaultProps,
store,
localVue,
});
};
describe('when test reports are supplied', () => {
beforeEach(() => createComponent());
const findErrorIcon = () => wrapper.find({ ref: 'suiteErrorIcon' });
it('renders the correct number of rows', () => {
expect(noSuitesToShow().exists()).toBe(false);
expect(allSuitesRows().length).toBe(testReports.test_suites.length);
});
describe('when there is a suite error', () => {
beforeEach(() => {
createComponent({
test_suites: [
{
...testReports.test_suites[0],
suite_error: 'Suite Error',
},
],
});
});
it('renders error icon', () => {
expect(findErrorIcon().exists()).toBe(true);
expect(findErrorIcon().attributes('title')).toEqual('Suite Error');
});
});
describe('when there is not a suite error', () => {
beforeEach(() => {
createComponent({
test_suites: [
{
...testReports.test_suites[0],
suite_error: null,
},
],
});
});
it('does not render error icon', () => {
expect(findErrorIcon().exists()).toBe(false);
});
});
});
describe('when there are no test suites', () => {
beforeEach(() => {
createComponent({ test_suites: [] });
});
it('displays the no suites to show message', () => {
expect(noSuitesToShow().exists()).toBe(true);
});
});
});
|