soloPanelCtrl-specs.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. beforeEach(module('grafana.routes'));
  14. beforeEach(module('grafana.services'));
  15. beforeEach(ctx.providePhase({
  16. $routeParams: routeParams,
  17. contextSrv: contextSrv,
  18. $location: {
  19. search: function() {
  20. return search;
  21. }
  22. },
  23. templateValuesSrv: { init: sinon.stub() },
  24. backendSrv: backendSrv
  25. }));
  26. beforeEach(ctx.createControllerPhase('SoloPanelCtrl'));
  27. describe('setting up solo panel scope', function() {
  28. beforeEach(function() {
  29. var dashboard = {
  30. model: {
  31. rows: [
  32. {
  33. panels: [
  34. {
  35. id: 23,
  36. some: 'prop'
  37. }
  38. ]
  39. }
  40. ]
  41. }
  42. };
  43. routeParams.slug = "my dash";
  44. search.panelId = 23;
  45. backendSrv.getDashboard = sinon.stub().returns(ctx.$q.when(dashboard));
  46. ctx.scope.init();
  47. ctx.scope.$digest();
  48. });
  49. it('should load dashboard and extract panel and setup panel scope', function() {
  50. expect(ctx.scope.panel.id).to.be(23);
  51. expect(ctx.scope.panel.some).to.be('prop');
  52. });
  53. it('should hide sidemenu', function() {
  54. expect(contextSrv.sidemenu).to.be(false);
  55. });
  56. });
  57. });
  58. });