diff --git a/refstack-ui/app/shared/alerts/alertModalFactory.js b/refstack-ui/app/shared/alerts/alertModalFactory.js index 25f5e5e2..abeff4ae 100644 --- a/refstack-ui/app/shared/alerts/alertModalFactory.js +++ b/refstack-ui/app/shared/alerts/alertModalFactory.js @@ -27,16 +27,15 @@ refstackApp.factory('raiseAlert', refstackApp.controller('raiseAlertModalController', - ['$scope', '$modalInstance', '$interval', 'data', - function ($scope, $modalInstance, $interval, data) { + ['$scope', '$modalInstance', 'data', + function ($scope, $modalInstance, data) { 'use strict'; $scope.data = data; + + //wait for users click to close the pop up window. $scope.close = function() { $modalInstance.close(); }; - $interval(function(){ - $scope.close(); - }, 3000, 1); } ] ); diff --git a/refstack-ui/tests/unit/ControllerSpec.js b/refstack-ui/tests/unit/ControllerSpec.js index cff76699..0318f3dd 100644 --- a/refstack-ui/tests/unit/ControllerSpec.js +++ b/refstack-ui/tests/unit/ControllerSpec.js @@ -582,4 +582,34 @@ describe('Refstack controllers', function () { expect(scope.getTestListString()).toEqual(expectedString); }); }); + + describe('testRaiseAlertModalController', function() { + var data; + var scope, modalInstance; + + data = { + mode: 'success', + title: '', + text: 'operation successful' + }; + + beforeEach(inject(function ($rootScope, $controller) { + scope = $rootScope.$new(); + modalInstance = { + dismiss: jasmine.createSpy('modalInstance.dismiss'), + close: jasmine.createSpy('modalInstance.close') + }; + $controller('raiseAlertModalController', { + $scope: scope, + $modalInstance: modalInstance, + data: data + }); + })); + + it('should close', + function () { + scope.close(); + expect(modalInstance.close).toHaveBeenCalledWith(); + }); + }); });