diff options
author | Adriel Santiago <asantiago@gitlab.com> | 2019-03-07 09:39:45 +0000 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2019-03-07 09:39:45 +0000 |
commit | b7c4ddfc4c392afd16a495fb3f7ac8b0611b1fa4 (patch) | |
tree | faa6585f1f0ef0cd7d5b49abd475456f332106af /spec/javascripts | |
parent | 78a01253aa112de6b2c3feb6784c80982c3b3add (diff) | |
download | gitlab-ce-b7c4ddfc4c392afd16a495fb3f7ac8b0611b1fa4.tar.gz |
Fix cluster health charts
Render both usage and capacity in chart
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/monitoring/charts/area_spec.js | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/spec/javascripts/monitoring/charts/area_spec.js b/spec/javascripts/monitoring/charts/area_spec.js index 1b6fc456ceb..fb49290be19 100644 --- a/spec/javascripts/monitoring/charts/area_spec.js +++ b/spec/javascripts/monitoring/charts/area_spec.js @@ -75,15 +75,6 @@ describe('Area component', () => { expect(shallowWrapperContainsSlotText(glAreaChart, 'tooltipTitle', mockTitle)).toBe(true); }); - it('recieves tooltip content', () => { - const mockContent = 'mockContent'; - areaChart.vm.tooltip.content = mockContent; - - expect(shallowWrapperContainsSlotText(glAreaChart, 'tooltipContent', mockContent)).toBe( - true, - ); - }); - describe('when tooltip is showing deployment data', () => { beforeEach(() => { areaChart.vm.tooltip.isDeployment = true; @@ -111,6 +102,7 @@ describe('Area component', () => { const generateSeriesData = type => ({ seriesData: [ { + seriesName: areaChart.vm.chartData[0].name, componentSubType: type, value: [mockDate, 5.55555], }, @@ -128,7 +120,14 @@ describe('Area component', () => { }); it('formats tooltip content', () => { - expect(areaChart.vm.tooltip.content).toBe('CPU 5.556'); + expect(areaChart.vm.tooltip.content).toEqual([{ name: 'Core Usage', value: '5.556' }]); + expect( + shallowWrapperContainsSlotText( + areaChart.find(GlAreaChart), + 'tooltipContent', + 'Core Usage 5.556', + ), + ).toBe(true); }); }); @@ -168,12 +167,10 @@ describe('Area component', () => { describe('onResize', () => { const mockWidth = 233; - const mockHeight = 144; beforeEach(() => { spyOn(Element.prototype, 'getBoundingClientRect').and.callFake(() => ({ width: mockWidth, - height: mockHeight, })); areaChart.vm.onResize(); }); @@ -181,22 +178,25 @@ describe('Area component', () => { it('sets area chart width', () => { expect(areaChart.vm.width).toBe(mockWidth); }); - - it('sets area chart height', () => { - expect(areaChart.vm.height).toBe(mockHeight); - }); }); }); describe('computed', () => { describe('chartData', () => { + let chartData; + const seriesData = () => chartData[0]; + + beforeEach(() => { + ({ chartData } = areaChart.vm); + }); + it('utilizes all data points', () => { - expect(Object.keys(areaChart.vm.chartData)).toEqual(['Cores']); - expect(areaChart.vm.chartData.Cores.length).toBe(297); + expect(chartData.length).toBe(1); + expect(seriesData().data.length).toBe(297); }); it('creates valid data', () => { - const data = areaChart.vm.chartData.Cores; + const { data } = seriesData(); expect( data.filter(([time, value]) => new Date(time).getTime() > 0 && typeof value === 'number') @@ -215,12 +215,6 @@ describe('Area component', () => { }); }); - describe('xAxisLabel', () => { - it('constructs a label for the chart x-axis', () => { - expect(areaChart.vm.xAxisLabel).toBe('Core Usage'); - }); - }); - describe('yAxisLabel', () => { it('constructs a label for the chart y-axis', () => { expect(areaChart.vm.yAxisLabel).toBe('CPU'); |