update to test helper

This commit is contained in:
Torkel Ödegaard 2014-10-01 13:49:36 +02:00
parent 5530915b49
commit 7ad18da08e

View File

@ -24,7 +24,7 @@ define([
$provide.value('timeSrv', self.timeSrv); $provide.value('timeSrv', self.timeSrv);
$provide.value('templateSrv', self.templateSrv); $provide.value('templateSrv', self.templateSrv);
$provide.value('$element', self.$element); $provide.value('$element', self.$element);
_.each(mocks, function(key, value) { _.each(mocks, function(value, key) {
$provide.value(key, value); $provide.value(key, value);
}); });
}); });
@ -34,16 +34,20 @@ define([
return inject(function($controller, $rootScope, $q, $location) { return inject(function($controller, $rootScope, $q, $location) {
self.scope = $rootScope.$new(); self.scope = $rootScope.$new();
self.$location = $location; self.$location = $location;
self.scope.grafana = {};
self.scope.panel = {}; self.scope.panel = {};
self.scope.row = { panels:[] }; self.scope.row = { panels:[] };
self.scope.dashboard = {}; self.scope.dashboard = {};
self.scope.dashboardViewState = new DashboardViewStateStub(); self.scope.dashboardViewState = new DashboardViewStateStub();
self.scope.appEvent = sinon.spy();
self.scope.onAppEvent = sinon.spy();
$rootScope.colors = []; $rootScope.colors = [];
for (var i = 0; i < 50; i++) { $rootScope.colors.push('#' + i); } for (var i = 0; i < 50; i++) { $rootScope.colors.push('#' + i); }
self.$q = $q; self.$q = $q;
self.scope.skipDataOnInit = true; self.scope.skipDataOnInit = true;
self.scope.skipAutoInit = true;
self.controller = $controller(controllerName, { self.controller = $controller(controllerName, {
$scope: self.scope $scope: self.scope
}); });
@ -87,6 +91,7 @@ define([
} }
function TimeSrvStub() { function TimeSrvStub() {
this.init = sinon.spy();
this.time = { from:'now-1h', to: 'now'}; this.time = { from:'now-1h', to: 'now'};
this.timeRange = function(parse) { this.timeRange = function(parse) {
if (parse === false) { if (parse === false) {