From 8f730eb46f1a2e42d4b7527a138ebbd63501d985 Mon Sep 17 00:00:00 2001 From: david liu Date: Fri, 18 Sep 2015 16:51:05 +0800 Subject: [PATCH] Refstack pop up window should remain open before users click close. Closes-Bug: #1492360 Change-Id: I91a56602e69e795f3d1e94dba89d50253ada0da6 --- .../app/shared/alerts/alertModalFactory.js | 9 +++--- refstack-ui/tests/unit/ControllerSpec.js | 30 +++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) 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(); + }); + }); });