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