From 5665e91ade9e16ec39e3d7e82e31849ef3554ce4 Mon Sep 17 00:00:00 2001 From: Jose Vargas Date: Thu, 6 Jun 2019 13:35:29 -0500 Subject: [PATCH] Add column chart component to the monitoring bundle This merge request just adds the column chart component without integrating it to the dashboard --- .../monitoring/components/charts/column.vue | 131 ++++++++++++++++++ .../monitoring/charts/column_spec.js | 58 ++++++++ 2 files changed, 189 insertions(+) create mode 100644 app/assets/javascripts/monitoring/components/charts/column.vue create mode 100644 spec/javascripts/monitoring/charts/column_spec.js diff --git a/app/assets/javascripts/monitoring/components/charts/column.vue b/app/assets/javascripts/monitoring/components/charts/column.vue new file mode 100644 index 00000000000..05a2036f4c3 --- /dev/null +++ b/app/assets/javascripts/monitoring/components/charts/column.vue @@ -0,0 +1,131 @@ + + diff --git a/spec/javascripts/monitoring/charts/column_spec.js b/spec/javascripts/monitoring/charts/column_spec.js new file mode 100644 index 00000000000..d8ac68b9484 --- /dev/null +++ b/spec/javascripts/monitoring/charts/column_spec.js @@ -0,0 +1,58 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlColumnChart } from '@gitlab/ui/dist/charts'; +import ColumnChart from '~/monitoring/components/charts/column.vue'; + +describe('Column component', () => { + let columnChart; + + beforeEach(() => { + columnChart = shallowMount(ColumnChart, { + propsData: { + graphData: { + queries: [ + { + x_label: 'Time', + y_label: 'Usage', + result: [ + { + metric: {}, + values: [ + [1495700554.925, '8.0390625'], + [1495700614.925, '8.0390625'], + [1495700674.925, '8.0390625'], + ], + }, + ], + }, + ], + }, + containerWidth: 100, + }, + }); + }); + + afterEach(() => { + columnChart.destroy(); + }); + + describe('wrapped components', () => { + describe('GitLab UI column chart', () => { + let glColumnChart; + + beforeEach(() => { + glColumnChart = columnChart.find(GlColumnChart); + }); + + it('is a Vue instance', () => { + expect(glColumnChart.isVueInstance()).toBe(true); + }); + + it('receives data properties needed for proper chart render', () => { + const props = glColumnChart.props(); + + expect(props.data).toBe(columnChart.vm.chartData); + expect(props.option).toBe(columnChart.vm.chartOptions); + }); + }); + }); +});