diff --git a/app/js/timer.js b/app/js/timer.js index 77f70d9..6daf62e 100644 --- a/app/js/timer.js +++ b/app/js/timer.js @@ -31,7 +31,7 @@ angular.module('timer', []) function resetTimeout() { if ($scope.timeoutId) { - $timeout.cancel($scope.timeoutId); + clearTimeout($scope.timeoutId); } } @@ -49,7 +49,7 @@ angular.module('timer', []) $scope.stop = $element[0].stop = function () { $scope.stoppedTime = new Date(); - $timeout.cancel($scope.timeoutId); + clearTimeout($scope.timeoutId); $scope.timeoutId = null; }; @@ -74,9 +74,16 @@ angular.module('timer', []) $scope.seconds = Math.floor(($scope.millis / 1000) % 60); $scope.minutes = Math.floor((($scope.millis / (1000 * 60)) % 60)); $scope.hours = Math.floor((($scope.millis / (1000 * 60 * 60)) % 24)); - $scope.timeoutId = $timeout(function () { + // Workaround to allow e2e tests ,we can't use $timout which make the + // e2e to hang + $scope.timeoutId = setTimeout(function() { tick(); + $scope.$apply(); }, $scope.interval); +// $scope.timeoutId = $timeout(function() { +// tick(); +// //$scope.$apply(); +// }, $scope.interval); $scope.$emit('timer-tick', {timeoutId: $scope.timeoutId, millis: $scope.millis}); }; diff --git a/config/karma-e2e.conf.js b/config/karma-e2e.conf.js index e99e717..3849858 100644 --- a/config/karma-e2e.conf.js +++ b/config/karma-e2e.conf.js @@ -7,14 +7,14 @@ files = [ 'test/e2e/**/*.js' ]; -autoWatch = false; +autoWatch = true; -browsers = ['Chrome']; +browsers = ['Firefox']; -singleRun = true; +singleRun = false; proxies = { - '/': 'http://localhost:8000/' + '/': 'http://localhost:8383/' }; junitReporter = { diff --git a/examples.html b/examples.html index d76d559..7a2169f 100644 --- a/examples.html +++ b/examples.html @@ -249,7 +249,7 @@

AngularJS - Polling Timers

}; $scope.$on('timer-tick', function (event, args) { - $scope.timerConsole += $scope.timerType + ' - event.name = '+ event.name + ', timeoutId = ' + args.timeoutId.$$timeoutId + ', millis = ' + args.millis +'\n'; + $scope.timerConsole += $scope.timerType + ' - event.name = '+ event.name + ', timeoutId = ' + args.timeoutId + ', millis = ' + args.millis +'\n'; }); } diff --git a/examples/angularjs-polling-timer.html b/examples/angularjs-polling-timer.html index 40b604f..a7928c8 100644 --- a/examples/angularjs-polling-timer.html +++ b/examples/angularjs-polling-timer.html @@ -23,7 +23,7 @@ }; $scope.$on('timer-tick', function (event, args) { - $scope.timerConsole += $scope.timerType + ' - event.name = '+ event.name + ', timeoutId = ' + args.timeoutId.$$timeoutId + ', millis = ' + args.millis +'\n'; + $scope.timerConsole += $scope.timerType + ' - event.name = '+ event.name + ', timeoutId = ' + args.timeoutId + ', millis = ' + args.millis +'\n'; }); } diff --git a/scripts/libpeerconnection.log b/scripts/libpeerconnection.log new file mode 100644 index 0000000..e69de29 diff --git a/test/e2e/scenarios.js b/test/e2e/scenarios.js index 81462f4..608a07f 100644 --- a/test/e2e/scenarios.js +++ b/test/e2e/scenarios.js @@ -5,13 +5,23 @@ describe('timer directive', function() { beforeEach(function() { - browser().navigateTo('../../index.html'); + browser().navigateTo('angular-timer/index.html'); }); - it('Simple timer', function() { - sleep(2); - var basicExample = angular.element('#timer1'); - console.log('######## basicExample = ', basicExample.html()); + it('should stop when user click on stop button [Simple Timer]', function() { + sleep(1); + element('#basic-timer button:last-child').click(); + var oldValue = element('#basic-timer span').text(); + sleep(1); + expect( element('#basic-timer span').text() ).toBe( oldValue ); + }); + + it('should be reset when user click on start button again [Simple Timer]', function() { + sleep(1); + var oldValue = element('#basic-timer span').text(); + element('#basic-timer button:nth-child(3)').click(); + element('#basic-timer button:last-child').click(); + expect( element('#basic-timer span').text() ).toBeLessThan( oldValue ); }); });