diff options
author | bikebilly <fabio@gitlab.com> | 2017-08-03 10:05:56 +0200 |
---|---|---|
committer | bikebilly <fabio@gitlab.com> | 2017-08-03 10:05:56 +0200 |
commit | 40dfddd4077da4d594bd9e8956e1fcb1c99434e6 (patch) | |
tree | d0761ed84471c22b3b0949720e3e0734e8645aac /spec/javascripts/monitoring/monitoring_spec.js | |
parent | ed5445388de13f1d126fec14cc0a9ea9ae03b397 (diff) | |
parent | dc412b48693668f7fba3adea57b8be76685afa76 (diff) | |
download | gitlab-ce-40dfddd4077da4d594bd9e8956e1fcb1c99434e6.tar.gz |
Merge branch 'master' into 33329-tech-article-deploying-maven-artifacts
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(); + }); + }); + }); +}); |