diff --git a/src/loading-bar.js b/src/loading-bar.js index 44e092a..2ba40fd 100644 --- a/src/loading-bar.js +++ b/src/loading-bar.js @@ -244,7 +244,7 @@ angular.module('cfp.loadingBar', []) // increment loadingbar to give the illusion that there is always // progress but make sure to cancel the previous timeouts so we don't // have multiple incs running at the same time. - if (autoIncrement) { + if (autoIncrement && status < 0.99) { $timeout.cancel(incTimeout); incTimeout = $timeout(function() { _inc(); diff --git a/test/loading-bar-interceptor.coffee b/test/loading-bar-interceptor.coffee index 241967f..f7fe88e 100644 --- a/test/loading-bar-interceptor.coffee +++ b/test/loading-bar-interceptor.coffee @@ -341,6 +341,11 @@ describe 'loadingBarInterceptor Service', -> $timeout.flush() width2 = lbar.children().css('width').slice(0, -1) expect(width2).toBe width + $timeout.verifyNoPendingTasks() + + # stops timeout: + cfpLoadingBar.set(0.993) + $timeout.verifyNoPendingTasks() cfpLoadingBar.complete()