diff options
| author | Chirayu Krishnappa | 2013-07-31 11:53:02 -0700 |
|---|---|---|
| committer | Chirayu Krishnappa | 2013-07-31 13:38:24 -0700 |
| commit | f274c0a66b28711d3b9cc7b0775e97755dd971e8 (patch) | |
| tree | 8959b8143f4158d46e3f921955da918269752fed /src/ngMock | |
| parent | 664526d69c927370c93a06745ca38de7cd03a7be (diff) | |
| download | angular.js-f274c0a66b28711d3b9cc7b0775e97755dd971e8.tar.bz2 | |
fix(mock.$log): keep in sync with $log
Closes #2343
Diffstat (limited to 'src/ngMock')
| -rw-r--r-- | src/ngMock/angular-mocks.js | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index bfb601fd..f7a9fec7 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -309,18 +309,32 @@ angular.mock.$ExceptionHandlerProvider = function() { * */ angular.mock.$LogProvider = function() { + var debug = true; function concat(array1, array2, index) { return array1.concat(Array.prototype.slice.call(array2, index)); } + this.debugEnabled = function(flag) { + if (isDefined(flag)) { + debug = flag; + return this; + } else { + return debug; + } + }; this.$get = function () { var $log = { log: function() { $log.log.logs.push(concat([], arguments, 0)); }, warn: function() { $log.warn.logs.push(concat([], arguments, 0)); }, info: function() { $log.info.logs.push(concat([], arguments, 0)); }, - error: function() { $log.error.logs.push(concat([], arguments, 0)); } + error: function() { $log.error.logs.push(concat([], arguments, 0)); }, + debug: function() { + if (debug) { + $log.debug.logs.push(concat([], arguments, 0)); + } + } }; /** @@ -349,34 +363,34 @@ angular.mock.$LogProvider = function() { $log.log.logs = []; /** * @ngdoc property - * @name ngMock.$log#warn.logs + * @name ngMock.$log#info.logs * @propertyOf ngMock.$log * * @description - * Array of messages logged using {@link ngMock.$log#warn}. + * Array of messages logged using {@link ngMock.$log#info}. * * @example * <pre> - * $log.warn('Some Warning'); - * var first = $log.warn.logs.unshift(); + * $log.info('Some Info'); + * var first = $log.info.logs.unshift(); * </pre> */ - $log.warn.logs = []; + $log.info.logs = []; /** * @ngdoc property - * @name ngMock.$log#info.logs + * @name ngMock.$log#warn.logs * @propertyOf ngMock.$log * * @description - * Array of messages logged using {@link ngMock.$log#info}. + * Array of messages logged using {@link ngMock.$log#warn}. * * @example * <pre> - * $log.info('Some Info'); - * var first = $log.info.logs.unshift(); + * $log.warn('Some Warning'); + * var first = $log.warn.logs.unshift(); * </pre> */ - $log.info.logs = []; + $log.warn.logs = []; /** * @ngdoc property * @name ngMock.$log#error.logs @@ -392,6 +406,21 @@ angular.mock.$LogProvider = function() { * </pre> */ $log.error.logs = []; + /** + * @ngdoc property + * @name ngMock.$log#debug.logs + * @propertyOf ngMock.$log + * + * @description + * Array of messages logged using {@link ngMock.$log#debug}. + * + * @example + * <pre> + * $log.debug('Some Error'); + * var first = $log.debug.logs.unshift(); + * </pre> + */ + $log.debug.logs = [] }; /** @@ -404,7 +433,7 @@ angular.mock.$LogProvider = function() { */ $log.assertEmpty = function() { var errors = []; - angular.forEach(['error', 'warn', 'info', 'log'], function(logLevel) { + angular.forEach(['error', 'warn', 'info', 'log', 'debug'], function(logLevel) { angular.forEach($log[logLevel].logs, function(log) { angular.forEach(log, function (logItem) { errors.push('MOCK $log (' + logLevel + '): ' + String(logItem) + '\n' + (logItem.stack || '')); |
