aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorColin Casey2013-09-20 21:33:16 -0300
committerBrian Ford2013-09-27 16:44:21 -0700
commit4ff1a65031e985bf930f6761c1ecf46e4db98d6e (patch)
tree9379887dfc410691c02bde62ba78210b1c6b87ad /test
parent21527db747ed24ba352b04aa6386550fae3c5fab (diff)
downloadangular.js-4ff1a65031e985bf930f6761c1ecf46e4db98d6e.tar.bz2
fix(log): prevent logging `undefined` for $log in IE
Closes #1705
Diffstat (limited to 'test')
-rw-r--r--test/ng/logSpec.js60
1 files changed, 41 insertions, 19 deletions
diff --git a/test/ng/logSpec.js b/test/ng/logSpec.js
index b416e044..4cac5c5c 100644
--- a/test/ng/logSpec.js
+++ b/test/ng/logSpec.js
@@ -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() {