Fixed unit tests for dashboardViewStateSrv
This commit is contained in:
@@ -54,6 +54,10 @@ define([
|
||||
expect(model.title).to.be('No Title');
|
||||
});
|
||||
|
||||
it('should have panel id', function() {
|
||||
expect(graph.id).to.be(1);
|
||||
});
|
||||
|
||||
it('should move time and filtering list', function() {
|
||||
expect(model.time.from).to.be('now-1d');
|
||||
expect(model.templating.list[0]).to.be(1);
|
||||
@@ -78,34 +82,4 @@ define([
|
||||
|
||||
});
|
||||
|
||||
describe('when updating view state', function() {
|
||||
var viewState, location;
|
||||
|
||||
beforeEach(module('grafana.services'));
|
||||
|
||||
beforeEach(inject(function(dashboardSrv, $location) {
|
||||
viewState = dashboardSrv.createViewState();
|
||||
location = $location;
|
||||
}));
|
||||
|
||||
describe('to fullscreen true and edit true', function() {
|
||||
it('should update querystring and view state', function() {
|
||||
var updateState = { fullscreen: true, edit: true, panelId: 1 };
|
||||
viewState.update(updateState);
|
||||
expect(location.search()).to.eql(updateState);
|
||||
expect(viewState).to.eql(updateState);
|
||||
});
|
||||
});
|
||||
|
||||
describe('to fullscreen false', function() {
|
||||
it('should remove params from query string', function() {
|
||||
viewState.update({fullscreen: true, panelId: 1, edit: true});
|
||||
viewState.update({fullscreen: false});
|
||||
expect(location.search()).to.eql({});
|
||||
expect(viewState).to.eql({});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
define([
|
||||
'services/dashboard/dashboardViewStateSrv'
|
||||
], function() {
|
||||
'use strict';
|
||||
|
||||
describe('when updating view state', function() {
|
||||
var viewState, location;
|
||||
|
||||
beforeEach(module('grafana.services'));
|
||||
|
||||
beforeEach(inject(function(dashboardViewStateSrv, $location, $rootScope) {
|
||||
$rootScope.onAppEvent = function(){};
|
||||
viewState = dashboardViewStateSrv.create($rootScope);
|
||||
location = $location;
|
||||
}));
|
||||
|
||||
describe('to fullscreen true and edit true', function() {
|
||||
it('should update querystring and view state', function() {
|
||||
var updateState = { fullscreen: true, edit: true, panelId: 1 };
|
||||
viewState.update(updateState);
|
||||
expect(location.search()).to.eql(updateState);
|
||||
expect(viewState.fullscreen).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('to fullscreen false', function() {
|
||||
it('should remove params from query string', function() {
|
||||
viewState.update({fullscreen: true, panelId: 1, edit: true});
|
||||
viewState.update({fullscreen: false});
|
||||
expect(location.search()).to.eql({});
|
||||
expect(viewState.fullscreen).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@@ -26,7 +26,7 @@ define([
|
||||
self.scope.panel = {};
|
||||
self.scope.row = { panels:[] };
|
||||
self.scope.filter = new FilterSrvStub();
|
||||
self.scope.dashboardViewState = { update: function() {} };
|
||||
self.scope.dashboardViewState = new DashboardViewStateStub();
|
||||
|
||||
$rootScope.colors = [];
|
||||
for (var i = 0; i < 50; i++) { $rootScope.colors.push('#' + i); }
|
||||
@@ -55,6 +55,11 @@ define([
|
||||
};
|
||||
}
|
||||
|
||||
function DashboardViewStateStub() {
|
||||
this.registerPanel = function() {
|
||||
};
|
||||
}
|
||||
|
||||
function FilterSrvStub() {
|
||||
this.time = { from:'now-1h', to: 'now'};
|
||||
this.timeRange = function(parse) {
|
||||
|
||||
@@ -124,6 +124,7 @@ require([
|
||||
'specs/filterSrv-specs',
|
||||
'specs/kbn-format-specs',
|
||||
'specs/dashboardSrv-specs',
|
||||
'specs/dashboardViewStateSrv-specs',
|
||||
'specs/influxSeries-specs'
|
||||
], function () {
|
||||
window.__karma__.start();
|
||||
|
||||
Reference in New Issue
Block a user