Skip to content

Commit

Permalink
Cleaned up logging for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Jun 8, 2015
1 parent febedcd commit 69eefa3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/components/services/predictiveCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ angular

var profiles = {};

function debug(...args) {
// disable debug messages for unit tests
if (!jasmine) {
console.debug.apply(null, args);
}

}

function validateProfile(settings) {
settings = angular.extend({}, defaults, settings);

Expand Down Expand Up @@ -169,7 +177,7 @@ angular
}

function invokeHttp(url) {
console.debug("predictiveCache:promiseResolution enqueued " + url);
debug("predictiveCache:promiseResolution enqueued " + url);
var config = {
url: url,
method: profile.method
Expand All @@ -179,7 +187,7 @@ angular
config = cfpLoadingBar.ignore(config);
}
return $http(config).then(function (value) {
console.debug("predictiveCache:promiseResolution completed " + url);
debug("predictiveCache:promiseResolution completed " + url);
return value;
});
}
Expand Down Expand Up @@ -232,7 +240,7 @@ angular
var batchCommands = array.slice(index, index + requestsPerProgression);
if (batchCommands.length !== 0) {
return promiseChain.then(function () {
//console.debug("execute next http requests", index / requestsPerProgression, batchCommands);
//debug("execute next http requests", index / requestsPerProgression, batchCommands);
if (batchCommands === 1) {
return invokeHttp(batchCommands[0]);
}
Expand All @@ -255,14 +263,14 @@ angular
promises = $q.all(commands.map(invokeHttp));
}

console.debug("predictiveCache:promiseResolution Promises enqueued");
debug("predictiveCache:promiseResolution Promises enqueued");

return promises
.catch(function (error) {
console.error("predictiveCache:promiseResolution " + error, error);
})
.finally(function () {
console.debug("predictiveCache:promiseResolution complete");
debug("predictiveCache:promiseResolution complete");
});
}

Expand Down

0 comments on commit 69eefa3

Please sign in to comment.