mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
parent
21527db747
commit
4ff1a65031
2 changed files with 41 additions and 19 deletions
|
|
@ -151,7 +151,7 @@ function $LogProvider(){
|
|||
// we are IE which either doesn't have window.console => this is noop and we do nothing,
|
||||
// or we are IE where console.log doesn't have apply so we log at least first 2 args
|
||||
return function(arg1, arg2) {
|
||||
logFn(arg1, arg2);
|
||||
logFn(arg1, arg2 == null ? '' : arg2);
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
|
|
|||
|
|
@ -69,21 +69,23 @@ describe('$log', function() {
|
|||
}
|
||||
));
|
||||
|
||||
describe("IE logging behavior", function() {
|
||||
function removeApplyFunctionForIE() {
|
||||
log.apply = log.call =
|
||||
warn.apply = warn.call =
|
||||
info.apply = info.call =
|
||||
error.apply = error.call =
|
||||
debug.apply = debug.call = null;
|
||||
|
||||
it("should work in IE where console.error doesn't have apply method", inject(
|
||||
function() {
|
||||
log.apply = log.call =
|
||||
warn.apply = warn.call =
|
||||
info.apply = info.call =
|
||||
error.apply = error.call =
|
||||
debug.apply = debug.call = null;
|
||||
$window.console = {log: log,
|
||||
warn: warn,
|
||||
info: info,
|
||||
error: error,
|
||||
debug: debug};
|
||||
}
|
||||
|
||||
$window.console = {log: log,
|
||||
warn: warn,
|
||||
info: info,
|
||||
error: error,
|
||||
debug: debug};
|
||||
},
|
||||
it("should work in IE where console.error doesn't have an apply method", inject(
|
||||
removeApplyFunctionForIE,
|
||||
function($log) {
|
||||
$log.log.apply($log);
|
||||
$log.warn.apply($log);
|
||||
|
|
@ -92,12 +94,32 @@ describe('$log', function() {
|
|||
$log.debug.apply($log);
|
||||
expect(logger).toEqual('log;warn;info;error;debug;');
|
||||
})
|
||||
);
|
||||
);
|
||||
|
||||
it("should not attempt to log the second argument in IE if it is not specified", inject(
|
||||
function() {
|
||||
log = function(arg1, arg2) { logger+= 'log;' + arg2; };
|
||||
warn = function(arg1, arg2) { logger+= 'warn;' + arg2; };
|
||||
info = function(arg1, arg2) { logger+= 'info;' + arg2; };
|
||||
error = function(arg1, arg2) { logger+= 'error;' + arg2; };
|
||||
debug = function(arg1, arg2) { logger+= 'debug;' + arg2; };
|
||||
},
|
||||
removeApplyFunctionForIE,
|
||||
function($log) {
|
||||
$log.log();
|
||||
$log.warn();
|
||||
$log.info();
|
||||
$log.error();
|
||||
$log.debug();
|
||||
expect(logger).toEqual('log;warn;info;error;debug;');
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
describe("$log.debug", function () {
|
||||
|
||||
|
||||
beforeEach(initService(false));
|
||||
|
||||
|
||||
it("should skip debugging output if disabled", inject(
|
||||
function(){
|
||||
$window.console = {log: log,
|
||||
|
|
@ -105,7 +127,7 @@ describe('$log', function() {
|
|||
info: info,
|
||||
error: error,
|
||||
debug: debug};
|
||||
},
|
||||
},
|
||||
function($log) {
|
||||
$log.log();
|
||||
$log.warn();
|
||||
|
|
@ -115,7 +137,7 @@ describe('$log', function() {
|
|||
expect(logger).toEqual('log;warn;info;error;');
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('$log.error', function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue