diff options
author | Phil Hughes <me@iamphill.com> | 2017-06-20 08:50:31 +0000 |
---|---|---|
committer | Jose Ivan Vargas Lopez <jvargas@gitlab.com> | 2017-06-26 14:44:03 +0000 |
commit | 871bf96c9b231b5c2281a021599959c4f164b479 (patch) | |
tree | 31b12a94ae2faaf39792f75f2b117a94df0ade01 /spec/javascripts/monitoring/monitoring_spec.js | |
parent | 676c559409b8b51e3e97abab24bbb44207744e13 (diff) | |
download | gitlab-ce-871bf96c9b231b5c2281a021599959c4f164b479.tar.gz |
Merge branch 'additional-metrics-dashboard' into '28717-additional-metrics-review-branch'
Additional metrics dashboard
See merge request !11740
Diffstat (limited to 'spec/javascripts/monitoring/monitoring_spec.js')
-rw-r--r-- | spec/javascripts/monitoring/monitoring_spec.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/javascripts/monitoring/monitoring_spec.js b/spec/javascripts/monitoring/monitoring_spec.js new file mode 100644 index 00000000000..6c7b691baa4 --- /dev/null +++ b/spec/javascripts/monitoring/monitoring_spec.js @@ -0,0 +1,49 @@ +import Vue from 'vue'; +import Monitoring from '~/monitoring/components/monitoring.vue'; +import { MonitorMockInterceptor } from './mock_data'; + +describe('Monitoring', () => { + const fixtureName = 'environments/metrics/metrics.html.raw'; + let MonitoringComponent; + let component; + preloadFixtures(fixtureName); + + beforeEach(() => { + loadFixtures(fixtureName); + MonitoringComponent = Vue.extend(Monitoring); + }); + + describe('no metrics are available yet', () => { + it('shows a getting started empty state when no metrics are present', () => { + component = new MonitoringComponent({ + el: document.querySelector('#prometheus-graphs'), + }); + + component.$mount(); + expect(component.$el.querySelector('#prometheus-graphs')).toBe(null); + expect(component.state).toEqual('gettingStarted'); + }); + }); + + describe('requests information to the server', () => { + beforeEach(() => { + document.querySelector('#prometheus-graphs').setAttribute('data-has-metrics', 'true'); + Vue.http.interceptors.push(MonitorMockInterceptor); + }); + + afterEach(() => { + Vue.http.interceptors = _.without(Vue.http.interceptors, MonitorMockInterceptor); + }); + + it('shows up a loading state', (done) => { + component = new MonitoringComponent({ + el: document.querySelector('#prometheus-graphs'), + }); + component.$mount(); + Vue.nextTick(() => { + expect(component.state).toEqual('loading'); + done(); + }); + }); + }); +}); |