mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Convert dates and regexps to string, test these and some other
non-standard values. Tests will probably fail on IE5-7 :(.
This commit is contained in:
@@ -115,7 +115,8 @@ _.each(['debug', 'info', 'warn', 'error'], function (level) {
|
||||
intercepted = true;
|
||||
}
|
||||
|
||||
var obj = (_.isObject(arg)) ? arg : {message: new String(arg).toString() };
|
||||
var obj = (_.isObject(arg) && !_.isRegExp(arg) && !_.isDate(arg) ) ?
|
||||
arg : {message: new String(arg).toString() };
|
||||
|
||||
_.each(RESTRICTED_KEYS, function (key) {
|
||||
if (obj[key])
|
||||
|
||||
@@ -47,25 +47,30 @@ Tinytest.add("logging - log", function (test) {
|
||||
test.instanceOf(obj3.time, Date);
|
||||
|
||||
// Test logging falsy values, as well as single digits
|
||||
Log._intercept(4);
|
||||
// and some other non-stringy things
|
||||
Log._intercept(9);
|
||||
log(1);
|
||||
log(0);
|
||||
log(null);
|
||||
log(undefined);
|
||||
log(new Date('Wed Jun 12 2013 18:15:16 GMT-0700 (PDT)'));
|
||||
log(/[^regexp]{0,1}/g);
|
||||
log(true);
|
||||
log(false);
|
||||
log(-Infinity);
|
||||
|
||||
intercepted = Log._intercepted();
|
||||
var expected = ['1', '0', 'null', 'undefined', 'Wed Jun 12 2013 18:15:16 GMT-0700 (PDT)', "/[^regexp]{0,1}/g", 'true', 'false', '-Infinity'];
|
||||
var testNames = ['single digit', 'falsy - 0', 'falsy - null', 'falsy - undefined', 'date', 'regexp', 'boolean - true', 'boolean - false', 'number - -Infinity'];
|
||||
|
||||
var obj4 = EJSON.parse(intercepted[0]);
|
||||
test.equal(obj4.message, "1", "Logging single digit");
|
||||
test.equal(intercepted.length, 9);
|
||||
|
||||
var obj5 = EJSON.parse(intercepted[1]);
|
||||
test.equal(obj5.message, "0", "Logging falsy value: 0");
|
||||
|
||||
var obj6 = EJSON.parse(intercepted[2]);
|
||||
test.equal(obj6.message, "null", "Logging falsy value: null");
|
||||
|
||||
var obj7 = EJSON.parse(intercepted[3]);
|
||||
test.equal(obj7.message, "undefined", "Logging falsy value: undefined");
|
||||
_.each(_.zip(expected, intercepted, testNames), function (expectedRecievedTest) {
|
||||
(function (expected, recieved, testName) {
|
||||
var obj = EJSON.parse(recieved);
|
||||
test.equal(obj.message, expected, 'Logging ' + testName);
|
||||
}).apply(this, expectedRecievedTest);
|
||||
});
|
||||
|
||||
// Tests for correct exceptions
|
||||
Log._intercept(6);
|
||||
|
||||
Reference in New Issue
Block a user