The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/src/test/specs/soloPanelCtrl-specs.js

63 lines
1.4 KiB

define([
'helpers',
'features/dashboard/soloPanelCtrl',
'features/dashboard/dashboardSrv',
], function(helpers) {
'use strict';
describe('SoloPanelCtrl', function() {
var ctx = new helpers.ControllerTestContext();
var datasource = {};
var routeParams = {};
var search = {};
beforeEach(module('grafana.routes'));
beforeEach(module('grafana.services'));
beforeEach(ctx.providePhase({
$routeParams: routeParams,
$location: {
search: function() {
return search;
}
},
datasourceSrv: {
getGrafanaDB: sinon.stub().returns(datasource)
}
}));
beforeEach(ctx.createControllerPhase('SoloPanelCtrl'));
describe('setting up solo panel scope', function() {
beforeEach(function() {
var dashboard = {
rows: [
{
panels: [
{
id: 23,
some: 'prop'
}
]
}
]
};
routeParams.id = 1;
search.panelId = 23;
datasource.getDashboard = sinon.stub().returns(ctx.$q.when(dashboard));
ctx.scope.init();
ctx.scope.$digest();
});
it('should load dashboard and extract panel and setup panel scope', function() {
expect(ctx.scope.panel.id).to.be(23);
expect(ctx.scope.panel.some).to.be('prop');
});
});
});
});