debian-mirror-gitlab/spec/javascripts/monitoring/graph/legend_spec.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import GraphLegend from '~/monitoring/components/graph/legend.vue';
import createTimeSeries from '~/monitoring/utils/multiple_time_series';
2018-05-09 12:01:36 +05:30
import mountComponent from 'spec/helpers/vue_mount_component_helper';
2018-03-17 18:26:18 +05:30
import { singleRowMetricsMultipleSeries, convertDatesMultipleSeries } from '../mock_data';
const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries);
2018-05-09 12:01:36 +05:30
const defaultValuesComponent = {};
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
const timeSeries = createTimeSeries(convertedMetrics[0].queries, 500, 300, 120);
2018-03-17 18:26:18 +05:30
defaultValuesComponent.timeSeries = timeSeries;
2018-05-09 12:01:36 +05:30
describe('Legend Component', () => {
let vm;
let Legend;
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
beforeEach(() => {
Legend = Vue.extend(GraphLegend);
2018-03-17 18:26:18 +05:30
});
2018-05-09 12:01:36 +05:30
describe('View', () => {
beforeEach(() => {
vm = mountComponent(Legend, {
legendTitle: 'legend',
timeSeries,
currentDataIndex: 0,
unitOfDisplay: 'Req/Sec',
});
2018-03-17 18:26:18 +05:30
});
2018-05-09 12:01:36 +05:30
it('should render the usage, title and time with multiple time series', () => {
const titles = vm.$el.querySelectorAll('.legend-metric-title');
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
expect(titles[0].textContent.indexOf('1xx')).not.toEqual(-1);
expect(titles[1].textContent.indexOf('2xx')).not.toEqual(-1);
2018-03-17 18:26:18 +05:30
});
2018-05-09 12:01:36 +05:30
it('should container the same number of rows in the table as time series', () => {
expect(vm.$el.querySelectorAll('.prometheus-table tr').length).toEqual(vm.timeSeries.length);
});
2018-03-17 18:26:18 +05:30
});
});