2019-12-26 22:10:19 +05:30
|
|
|
import Vuex from 'vuex';
|
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-01-01 13:55:28 +05:30
|
|
|
import { getJSONFixture } from 'helpers/fixtures';
|
|
|
|
import TestReports from '~/pipelines/components/test_reports/test_reports.vue';
|
2019-12-26 22:10:19 +05:30
|
|
|
import * as actions from '~/pipelines/stores/test_reports/actions';
|
|
|
|
|
|
|
|
describe('Test reports app', () => {
|
|
|
|
let wrapper;
|
|
|
|
let store;
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
const testReports = getJSONFixture('pipelines/test_report.json');
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
const loadingSpinner = () => wrapper.find('.js-loading-spinner');
|
|
|
|
const testsDetail = () => wrapper.find('.js-tests-detail');
|
|
|
|
const noTestsToShow = () => wrapper.find('.js-no-tests-to-show');
|
|
|
|
|
|
|
|
const createComponent = (state = {}) => {
|
|
|
|
store = new Vuex.Store({
|
|
|
|
state: {
|
|
|
|
isLoading: false,
|
|
|
|
selectedSuite: {},
|
|
|
|
testReports,
|
|
|
|
...state,
|
|
|
|
},
|
|
|
|
actions,
|
|
|
|
});
|
|
|
|
|
|
|
|
wrapper = shallowMount(TestReports, {
|
|
|
|
store,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when loading', () => {
|
|
|
|
beforeEach(() => createComponent({ isLoading: true }));
|
|
|
|
|
|
|
|
it('shows the loading spinner', () => {
|
|
|
|
expect(noTestsToShow().exists()).toBe(false);
|
|
|
|
expect(testsDetail().exists()).toBe(false);
|
|
|
|
expect(loadingSpinner().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the api returns no data', () => {
|
|
|
|
beforeEach(() => createComponent({ testReports: {} }));
|
|
|
|
|
|
|
|
it('displays that there are no tests to show', () => {
|
|
|
|
const noTests = noTestsToShow();
|
|
|
|
|
|
|
|
expect(noTests.exists()).toBe(true);
|
|
|
|
expect(noTests.text()).toBe('There are no tests to show.');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when the api returns data', () => {
|
|
|
|
beforeEach(() => createComponent());
|
|
|
|
|
|
|
|
it('sets testReports and shows tests', () => {
|
|
|
|
expect(wrapper.vm.testReports).toBeTruthy();
|
|
|
|
expect(wrapper.vm.showTests).toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|