2020-01-31 13:09:11 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import { GlColumnChart } from '@gitlab/ui/dist/charts';
|
2020-02-03 07:09:07 -05:00
|
|
|
import Component from '~/projects/pipelines/charts/components/app.vue';
|
|
|
|
import StatisticsList from '~/projects/pipelines/charts/components/statistics_list.vue';
|
2020-02-11 07:08:52 -05:00
|
|
|
import PipelinesAreaChart from '~/projects/pipelines/charts/components/pipelines_area_chart.vue';
|
|
|
|
import {
|
|
|
|
counts,
|
|
|
|
timesChartData,
|
|
|
|
areaChartData as lastWeekChartData,
|
|
|
|
areaChartData as lastMonthChartData,
|
|
|
|
lastYearChartData,
|
|
|
|
} from '../mock_data';
|
2020-01-31 13:09:11 -05:00
|
|
|
|
|
|
|
describe('ProjectsPipelinesChartsApp', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper = shallowMount(Component, {
|
|
|
|
propsData: {
|
|
|
|
counts,
|
|
|
|
timesChartData,
|
2020-02-11 07:08:52 -05:00
|
|
|
lastWeekChartData,
|
|
|
|
lastMonthChartData,
|
|
|
|
lastYearChartData,
|
2020-01-31 13:09:11 -05:00
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('overall statistics', () => {
|
|
|
|
it('displays the statistics list', () => {
|
|
|
|
const list = wrapper.find(StatisticsList);
|
|
|
|
|
|
|
|
expect(list.exists()).toBeTruthy();
|
|
|
|
expect(list.props('counts')).toBe(counts);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('displays the commit duration chart', () => {
|
|
|
|
const chart = wrapper.find(GlColumnChart);
|
|
|
|
|
|
|
|
expect(chart.exists()).toBeTruthy();
|
|
|
|
expect(chart.props('yAxisTitle')).toBe('Minutes');
|
|
|
|
expect(chart.props('xAxisTitle')).toBe('Commit');
|
|
|
|
expect(chart.props('data')).toBe(wrapper.vm.timesChartTransformedData);
|
|
|
|
expect(chart.props('option')).toBe(wrapper.vm.$options.timesChartOptions);
|
|
|
|
});
|
|
|
|
});
|
2020-02-11 07:08:52 -05:00
|
|
|
|
|
|
|
describe('pipelines charts', () => {
|
|
|
|
it('displays 3 area charts', () => {
|
|
|
|
expect(wrapper.findAll(PipelinesAreaChart).length).toBe(3);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('displays individual correctly', () => {
|
|
|
|
it('renders with the correct data', () => {
|
|
|
|
const charts = wrapper.findAll(PipelinesAreaChart);
|
|
|
|
|
|
|
|
for (let i = 0; i < charts.length; i += 1) {
|
|
|
|
const chart = charts.at(i);
|
|
|
|
|
|
|
|
expect(chart.exists()).toBeTruthy();
|
|
|
|
expect(chart.props('chartData')).toBe(wrapper.vm.areaCharts[i].data);
|
|
|
|
expect(chart.text()).toBe(wrapper.vm.areaCharts[i].title);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-01-31 13:09:11 -05:00
|
|
|
});
|