diff options
author | kushalpandya <kushal@gitlab.com> | 2017-06-01 18:54:56 +0300 |
---|---|---|
committer | kushalpandya <kushal@gitlab.com> | 2017-06-01 18:55:45 +0300 |
commit | 3f0eff82592f4a30abb6ffd15ac248a5f773c994 (patch) | |
tree | 5de7d573720215becb0bc82e038f97e0fa1a772a /spec/javascripts/prometheus_metrics | |
parent | 4c58fd82df71e1a8a4389cbbb8a5ea3b0186291c (diff) |
Update as per review feedback
Diffstat (limited to 'spec/javascripts/prometheus_metrics')
-rw-r--r-- | spec/javascripts/prometheus_metrics/prometheus_metrics_spec.js | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/spec/javascripts/prometheus_metrics/prometheus_metrics_spec.js b/spec/javascripts/prometheus_metrics/prometheus_metrics_spec.js index 8b4f386af80..e7187a8a5e0 100644 --- a/spec/javascripts/prometheus_metrics/prometheus_metrics_spec.js +++ b/spec/javascripts/prometheus_metrics/prometheus_metrics_spec.js @@ -1,4 +1,5 @@ import PrometheusMetrics from '~/prometheus_metrics/prometheus_metrics'; +import PANEL_STATE from '~/prometheus_metrics/constants'; import { metrics, missingVarMetrics } from './mock_data'; describe('PrometheusMetrics', () => { @@ -35,6 +36,38 @@ describe('PrometheusMetrics', () => { }); }); + describe('showMonitoringMetricsPanelState', () => { + let prometheusMetrics; + + beforeEach(() => { + prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring'); + }); + + it('should show loading state when called with `loading`', () => { + prometheusMetrics.showMonitoringMetricsPanelState(PANEL_STATE.LOADING); + + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeFalsy(); + expect(prometheusMetrics.$monitoredMetricsEmpty.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsList.hasClass('hidden')).toBeTruthy(); + }); + + it('should show metrics list when called with `list`', () => { + prometheusMetrics.showMonitoringMetricsPanelState(PANEL_STATE.LIST); + + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsEmpty.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsList.hasClass('hidden')).toBeFalsy(); + }); + + it('should show empty state when called with `empty`', () => { + prometheusMetrics.showMonitoringMetricsPanelState(PANEL_STATE.EMPTY); + + expect(prometheusMetrics.$monitoredMetricsLoading.hasClass('hidden')).toBeTruthy(); + expect(prometheusMetrics.$monitoredMetricsEmpty.hasClass('hidden')).toBeFalsy(); + expect(prometheusMetrics.$monitoredMetricsList.hasClass('hidden')).toBeTruthy(); + }); + }); + describe('populateActiveMetrics', () => { let prometheusMetrics; @@ -52,7 +85,7 @@ describe('PrometheusMetrics', () => { expect(prometheusMetrics.$monitoredMetricsCount.text()).toEqual('12'); expect($metricsListLi.length).toEqual(metrics.length); - expect($metricsListLi.first().find('.badge-count').text()).toEqual(`${metrics[0].active_metrics}`); + expect($metricsListLi.first().find('.badge').text()).toEqual(`${metrics[0].active_metrics}`); }); it('should show missing environment variables list', () => { |