debian-mirror-gitlab/spec/javascripts/monitoring/graph_path_spec.js

57 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import GraphPath from '~/monitoring/components/graph/path.vue';
import createTimeSeries from '~/monitoring/utils/multiple_time_series';
import { singleRowMetricsMultipleSeries, convertDatesMultipleSeries } from './mock_data';
2018-12-13 13:39:08 +05:30
const createComponent = propsData => {
2018-03-17 18:26:18 +05:30
const Component = Vue.extend(GraphPath);
return new Component({
propsData,
}).$mount();
};
const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries);
2018-12-05 23:21:45 +05:30
const { timeSeries } = createTimeSeries(convertedMetrics[0].queries, 428, 272, 120);
2018-03-17 18:26:18 +05:30
const firstTimeSeries = timeSeries[0];
describe('Monitoring Paths', () => {
it('renders two paths to represent a line and the area underneath it', () => {
const component = createComponent({
generatedLinePath: firstTimeSeries.linePath,
generatedAreaPath: firstTimeSeries.areaPath,
lineColor: firstTimeSeries.lineColor,
areaColor: firstTimeSeries.areaColor,
2018-10-15 14:42:47 +05:30
showDot: false,
2018-03-17 18:26:18 +05:30
});
const metricArea = component.$el.querySelector('.metric-area');
const metricLine = component.$el.querySelector('.metric-line');
expect(metricArea.getAttribute('fill')).toBe('#8fbce8');
expect(metricArea.getAttribute('d')).toBe(firstTimeSeries.areaPath);
expect(metricLine.getAttribute('stroke')).toBe('#1f78d1');
expect(metricLine.getAttribute('d')).toBe(firstTimeSeries.linePath);
});
describe('Computed properties', () => {
it('strokeDashArray', () => {
const component = createComponent({
generatedLinePath: firstTimeSeries.linePath,
generatedAreaPath: firstTimeSeries.areaPath,
lineColor: firstTimeSeries.lineColor,
areaColor: firstTimeSeries.areaColor,
2018-10-15 14:42:47 +05:30
showDot: false,
2018-03-17 18:26:18 +05:30
});
component.lineStyle = 'dashed';
2018-12-13 13:39:08 +05:30
2018-03-17 18:26:18 +05:30
expect(component.strokeDashArray).toBe('3, 1');
component.lineStyle = 'dotted';
2018-12-13 13:39:08 +05:30
2018-03-17 18:26:18 +05:30
expect(component.strokeDashArray).toBe('1, 1');
});
});
});