soloPanelCtrl-specs.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. define([
  2. 'helpers',
  3. 'features/panel/soloPanelCtrl',
  4. 'features/dashboard/dashboardSrv',
  5. ], function(helpers) {
  6. 'use strict';
  7. describe('SoloPanelCtrl', function() {
  8. var ctx = new helpers.ControllerTestContext();
  9. var backendSrv = {};
  10. var routeParams = {};
  11. var search = {};
  12. var contextSrv = {
  13. hasRole: sinon.stub().returns(true)
  14. };
  15. beforeEach(module('grafana.routes'));
  16. beforeEach(module('grafana.services'));
  17. beforeEach(ctx.providePhase({
  18. $routeParams: routeParams,
  19. contextSrv: contextSrv,
  20. $location: {
  21. search: function() {
  22. return search;
  23. }
  24. },
  25. templateValuesSrv: { init: sinon.stub() },
  26. backendSrv: backendSrv
  27. }));
  28. beforeEach(ctx.createControllerPhase('SoloPanelCtrl'));
  29. describe('setting up solo panel scope', function() {
  30. beforeEach(function() {
  31. var dashboard = {
  32. model: {
  33. rows: [
  34. {
  35. panels: [
  36. {
  37. id: 23,
  38. some: 'prop'
  39. }
  40. ]
  41. }
  42. ]
  43. },
  44. meta: {}
  45. };
  46. routeParams.slug = "my dash";
  47. search.panelId = 23;
  48. backendSrv.getDashboard = sinon.stub().returns(ctx.$q.when(dashboard));
  49. ctx.scope.init();
  50. ctx.scope.$digest();
  51. });
  52. it('should load dashboard and extract panel and setup panel scope', function() {
  53. expect(ctx.scope.panel.id).to.be(23);
  54. expect(ctx.scope.panel.some).to.be('prop');
  55. });
  56. it('should hide sidemenu', function() {
  57. expect(contextSrv.sidemenu).to.be(false);
  58. });
  59. });
  60. });
  61. });