Commit 4b892a5f authored by Mike Greiling's avatar Mike Greiling

update specs to match reorganized monitoring components

parent 147d55d2
import Vue from 'vue'; import Vue from 'vue';
import Monitoring from '~/monitoring/components/monitoring.vue'; import Dashboard from '~/monitoring/components/dashboard.vue';
import { MonitorMockInterceptor } from './mock_data'; import { MonitorMockInterceptor } from './mock_data';
describe('Monitoring', () => { describe('Dashboard', () => {
const fixtureName = 'environments/metrics/metrics.html.raw'; const fixtureName = 'environments/metrics/metrics.html.raw';
let MonitoringComponent; let DashboardComponent;
let component; let component;
preloadFixtures(fixtureName); preloadFixtures(fixtureName);
beforeEach(() => { beforeEach(() => {
loadFixtures(fixtureName); loadFixtures(fixtureName);
MonitoringComponent = Vue.extend(Monitoring); DashboardComponent = Vue.extend(Dashboard);
}); });
describe('no metrics are available yet', () => { describe('no metrics are available yet', () => {
it('shows a getting started empty state when no metrics are present', () => { it('shows a getting started empty state when no metrics are present', () => {
component = new MonitoringComponent({ component = new DashboardComponent({
el: document.querySelector('#prometheus-graphs'), el: document.querySelector('#prometheus-graphs'),
}); });
...@@ -36,7 +36,7 @@ describe('Monitoring', () => { ...@@ -36,7 +36,7 @@ describe('Monitoring', () => {
}); });
it('shows up a loading state', (done) => { it('shows up a loading state', (done) => {
component = new MonitoringComponent({ component = new DashboardComponent({
el: document.querySelector('#prometheus-graphs'), el: document.querySelector('#prometheus-graphs'),
}); });
component.$mount(); component.$mount();
......
import Vue from 'vue'; import Vue from 'vue';
import MonitoringState from '~/monitoring/components/monitoring_state.vue'; import EmptyState from '~/monitoring/components/empty_state.vue';
import { statePaths } from './mock_data'; import { statePaths } from './mock_data';
const createComponent = (propsData) => { const createComponent = (propsData) => {
const Component = Vue.extend(MonitoringState); const Component = Vue.extend(EmptyState);
return new Component({ return new Component({
propsData, propsData,
...@@ -14,7 +14,7 @@ function getTextFromNode(component, selector) { ...@@ -14,7 +14,7 @@ function getTextFromNode(component, selector) {
return component.$el.querySelector(selector).firstChild.nodeValue.trim(); return component.$el.querySelector(selector).firstChild.nodeValue.trim();
} }
describe('MonitoringState', () => { describe('EmptyState', () => {
describe('Computed props', () => { describe('Computed props', () => {
it('currentState', () => { it('currentState', () => {
const component = createComponent({ const component = createComponent({
......
import Vue from 'vue'; import Vue from 'vue';
import MonitoringState from '~/monitoring/components/monitoring_deployment.vue'; import GraphDeployment from '~/monitoring/components/graph/deployment.vue';
import { deploymentData } from './mock_data'; import { deploymentData } from '../mock_data';
const createComponent = (propsData) => { const createComponent = (propsData) => {
const Component = Vue.extend(MonitoringState); const Component = Vue.extend(GraphDeployment);
return new Component({ return new Component({
propsData, propsData,
......
import Vue from 'vue'; import Vue from 'vue';
import MonitoringFlag from '~/monitoring/components/monitoring_flag.vue'; import GraphFlag from '~/monitoring/components/graph/flag.vue';
const createComponent = (propsData) => { const createComponent = (propsData) => {
const Component = Vue.extend(MonitoringFlag); const Component = Vue.extend(GraphFlag);
return new Component({ return new Component({
propsData, propsData,
...@@ -14,7 +14,7 @@ function getCoordinate(component, selector, coordinate) { ...@@ -14,7 +14,7 @@ function getCoordinate(component, selector, coordinate) {
return parseInt(coordinateVal, 10); return parseInt(coordinateVal, 10);
} }
describe('MonitoringFlag', () => { describe('GraphFlag', () => {
it('has a line and a circle located at the currentXCoordinate and currentYCoordinate', () => { it('has a line and a circle located at the currentXCoordinate and currentYCoordinate', () => {
const component = createComponent({ const component = createComponent({
currentXCoordinate: 200, currentXCoordinate: 200,
......
import Vue from 'vue'; import Vue from 'vue';
import MonitoringLegends from '~/monitoring/components/monitoring_legends.vue'; import GraphLegend from '~/monitoring/components/graph/legend.vue';
import measurements from '~/monitoring/utils/measurements'; import measurements from '~/monitoring/utils/measurements';
const createComponent = (propsData) => { const createComponent = (propsData) => {
const Component = Vue.extend(MonitoringLegends); const Component = Vue.extend(GraphLegend);
return new Component({ return new Component({
propsData, propsData,
...@@ -14,7 +14,7 @@ function getTextFromNode(component, selector) { ...@@ -14,7 +14,7 @@ function getTextFromNode(component, selector) {
return component.$el.querySelector(selector).firstChild.nodeValue.trim(); return component.$el.querySelector(selector).firstChild.nodeValue.trim();
} }
describe('MonitoringLegends', () => { describe('GraphLegend', () => {
describe('Computed props', () => { describe('Computed props', () => {
it('textTransform', () => { it('textTransform', () => {
const component = createComponent({ const component = createComponent({
......
import Vue from 'vue'; import Vue from 'vue';
import MonitoringRow from '~/monitoring/components/monitoring_row.vue'; import GraphRow from '~/monitoring/components/graph_row.vue';
import MonitoringMixins from '~/monitoring/mixins/monitoring_mixins';
import { deploymentData, singleRowMetrics } from './mock_data'; import { deploymentData, singleRowMetrics } from './mock_data';
const createComponent = (propsData) => { const createComponent = (propsData) => {
const Component = Vue.extend(MonitoringRow); const Component = Vue.extend(GraphRow);
return new Component({ return new Component({
propsData, propsData,
}).$mount(); }).$mount();
}; };
describe('MonitoringRow', () => { describe('GraphRow', () => {
beforeEach(() => {
spyOn(MonitoringMixins.methods, 'formatDeployments').and.returnValue({});
});
describe('Computed props', () => { describe('Computed props', () => {
it('bootstrapClass is set to col-md-6 when rowData is higher/equal to 2', () => { it('bootstrapClass is set to col-md-6 when rowData is higher/equal to 2', () => {
const component = createComponent({ const component = createComponent({
......
import Vue from 'vue'; import Vue from 'vue';
import _ from 'underscore'; import _ from 'underscore';
import MonitoringColumn from '~/monitoring/components/monitoring_column.vue'; import Graph from '~/monitoring/components/graph.vue';
import MonitoringMixins from '~/monitoring/mixins/monitoring_mixins'; import MonitoringMixins from '~/monitoring/mixins/monitoring_mixins';
import eventHub from '~/monitoring/event_hub'; import eventHub from '~/monitoring/event_hub';
import { deploymentData, singleRowMetrics } from './mock_data'; import { deploymentData, singleRowMetrics } from './mock_data';
const createComponent = (propsData) => { const createComponent = (propsData) => {
const Component = Vue.extend(MonitoringColumn); const Component = Vue.extend(Graph);
return new Component({ return new Component({
propsData, propsData,
}).$mount(); }).$mount();
}; };
describe('MonitoringColumn', () => { describe('Graph', () => {
beforeEach(() => { beforeEach(() => {
spyOn(MonitoringMixins.methods, 'formatDeployments').and.callFake(function fakeFormat() { spyOn(MonitoringMixins.methods, 'formatDeployments').and.returnValue({});
return {};
});
}); });
it('has a title', () => { it('has a title', () => {
const component = createComponent({ const component = createComponent({
columnData: singleRowMetrics[0], graphData: singleRowMetrics[0],
classType: 'col-md-6', classType: 'col-md-6',
updateAspectRatio: false, updateAspectRatio: false,
deploymentData, deploymentData,
}); });
expect(component.$el.querySelector('.text-center').innerText.trim()).toBe(component.columnData.title); expect(component.$el.querySelector('.text-center').innerText.trim()).toBe(component.graphData.title);
}); });
it('creates a path for the line and area of the graph', (done) => { it('creates a path for the line and area of the graph', (done) => {
const component = createComponent({ const component = createComponent({
columnData: singleRowMetrics[0], graphData: singleRowMetrics[0],
classType: 'col-md-6', classType: 'col-md-6',
updateAspectRatio: false, updateAspectRatio: false,
deploymentData, deploymentData,
...@@ -53,7 +51,7 @@ describe('MonitoringColumn', () => { ...@@ -53,7 +51,7 @@ describe('MonitoringColumn', () => {
describe('Computed props', () => { describe('Computed props', () => {
it('axisTransform translates an element Y position depending of its height', () => { it('axisTransform translates an element Y position depending of its height', () => {
const component = createComponent({ const component = createComponent({
columnData: singleRowMetrics[0], graphData: singleRowMetrics[0],
classType: 'col-md-6', classType: 'col-md-6',
updateAspectRatio: false, updateAspectRatio: false,
deploymentData, deploymentData,
...@@ -66,7 +64,7 @@ describe('MonitoringColumn', () => { ...@@ -66,7 +64,7 @@ describe('MonitoringColumn', () => {
it('outterViewBox gets a width and height property based on the DOM size of the element', () => { it('outterViewBox gets a width and height property based on the DOM size of the element', () => {
const component = createComponent({ const component = createComponent({
columnData: singleRowMetrics[0], graphData: singleRowMetrics[0],
classType: 'col-md-6', classType: 'col-md-6',
updateAspectRatio: false, updateAspectRatio: false,
deploymentData, deploymentData,
...@@ -81,7 +79,7 @@ describe('MonitoringColumn', () => { ...@@ -81,7 +79,7 @@ describe('MonitoringColumn', () => {
it('sends an event to the eventhub when it has finished resizing', (done) => { it('sends an event to the eventhub when it has finished resizing', (done) => {
const component = createComponent({ const component = createComponent({
columnData: singleRowMetrics[0], graphData: singleRowMetrics[0],
classType: 'col-md-6', classType: 'col-md-6',
updateAspectRatio: false, updateAspectRatio: false,
deploymentData, deploymentData,
...@@ -97,13 +95,13 @@ describe('MonitoringColumn', () => { ...@@ -97,13 +95,13 @@ describe('MonitoringColumn', () => {
it('has a title for the y-axis and the chart legend that comes from the backend', () => { it('has a title for the y-axis and the chart legend that comes from the backend', () => {
const component = createComponent({ const component = createComponent({
columnData: singleRowMetrics[0], graphData: singleRowMetrics[0],
classType: 'col-md-6', classType: 'col-md-6',
updateAspectRatio: false, updateAspectRatio: false,
deploymentData, deploymentData,
}); });
expect(component.yAxisLabel).toEqual(component.columnData.y_label); expect(component.yAxisLabel).toEqual(component.graphData.y_label);
expect(component.legendTitle).toEqual(component.columnData.queries[0].label); expect(component.legendTitle).toEqual(component.graphData.queries[0].label);
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment