' 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. define([
  2. 'features/dashboard/unsavedChangesSrv',
  3. 'features/dashboard/dashboardSrv'
  4. ], function() {
  5. 'use strict';
  6. describe("unsavedChangesSrv", function() {
  7. var _unsavedChangesSrv;
  8. var _dashboardSrv;
  9. var _location;
  10. var _contextSrvStub = {
  11. isEditor: true
  12. };
  13. var _rootScope;
  14. var tracker;
  15. beforeEach(module('grafana.services'));
  16. beforeEach(module(function($provide) {
  17. $provide.value('contextSrv', _contextSrvStub);
  18. }));
  19. beforeEach(inject(function(unsavedChangesSrv, $location, $rootScope, dashboardSrv) {
  20. _unsavedChangesSrv = unsavedChangesSrv;
  21. _dashboardSrv = dashboardSrv;
  22. _location = $location;
  23. _rootScope = $rootScope;
  24. }));
  25. describe('when dashboard is modified and route changes', function() {
  26. beforeEach(function() {
  27. var dash = _dashboardSrv.create({});
  28. var scope = _rootScope.$new();
  29. scope.appEvent = sinon.spy();
  30. scope.onAppEvent = sinon.spy();
  31. tracker = _unsavedChangesSrv.constructor(dash, scope);
  32. });
  33. it('No changes should not have changes', function() {
  34. expect(tracker.hasChanges()).to.be(false);
  35. });
  36. });
  37. });
  38. });