Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. angular.module('MyApp')
  2. .directive('widgetContainer', function() {
  3. return {
  4. templateUrl: '/static/templates/container.html',
  5. controller: 'ContainerCtrl'
  6. };
  7. })
  8. .controller('ContainerCtrl', ['$scope', '$modal', function($scope, $modal) {
  9.  
  10. function editWidget(widget) {
  11. var modalInstance = $modal.open({
  12. templateUrl: '/static/templates//modal.html',
  13. controller: 'ModalInstanceCtrl',
  14. scope: $scope,
  15. size: 'lg',
  16. backdrop: 'static'
  17. });
  18. modalInstance.opened.then(function() {
  19. $scope.widgetCopy = editWidgetInit(widget);
  20. });
  21. modalInstance.result
  22. .then(function() {
  23. // some result
  24. });
  25. return modalInstance;
  26. }
  27.  
  28. function editWidgetInit(widget) {
  29. widgetCopy = setSelectedChart(widget);
  30. // lots of other setup tasks
  31. return widgetCopy;
  32. }
  33.  
  34. }]);
  35.  
  36. describe('on edit widget', function() {
  37. it('should setup selectedChart from widget', function() {
  38. var widget = {widget: {indicators: [{name: 'indicator'}]}};
  39. var modalInstance = scope.editWidget(widget);
  40. rootScope.$digest();
  41. expect(scope.selectedChart).toBe('pie');
  42. });
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement