From: Tim Wood Date: Wed, 21 Mar 2012 17:29:40 +0000 (-0700) Subject: Switching to toDate instead of native in all the tests X-Git-Tag: 1.5.1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97edd8591cfc77c982373d9eb94641df36a3c038;p=thirdparty%2Fmoment.git Switching to toDate instead of native in all the tests #216 #211 --- diff --git a/test/moment/create.js b/test/moment/create.js index 3a68557e9..ab02344c4 100644 --- a/test/moment/create.js +++ b/test/moment/create.js @@ -3,47 +3,47 @@ var moment = require("../../moment"); exports.create = { "array" : function(test) { test.expect(8); - test.ok(moment([2010]).native() instanceof Date, "[2010]"); - test.ok(moment([2010, 1]).native() instanceof Date, "[2010, 1]"); - test.ok(moment([2010, 1, 12]).native() instanceof Date, "[2010, 1, 12]"); - test.ok(moment([2010, 1, 12, 1]).native() instanceof Date, "[2010, 1, 12, 1]"); - test.ok(moment([2010, 1, 12, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1]"); - test.ok(moment([2010, 1, 12, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1]"); - test.ok(moment([2010, 1, 12, 1, 1, 1, 1]).native() instanceof Date, "[2010, 1, 12, 1, 1, 1, 1]"); + test.ok(moment([2010]).toDate() instanceof Date, "[2010]"); + test.ok(moment([2010, 1]).toDate() instanceof Date, "[2010, 1]"); + test.ok(moment([2010, 1, 12]).toDate() instanceof Date, "[2010, 1, 12]"); + test.ok(moment([2010, 1, 12, 1]).toDate() instanceof Date, "[2010, 1, 12, 1]"); + test.ok(moment([2010, 1, 12, 1, 1]).toDate() instanceof Date, "[2010, 1, 12, 1, 1]"); + test.ok(moment([2010, 1, 12, 1, 1, 1]).toDate() instanceof Date, "[2010, 1, 12, 1, 1, 1]"); + test.ok(moment([2010, 1, 12, 1, 1, 1, 1]).toDate() instanceof Date, "[2010, 1, 12, 1, 1, 1, 1]"); test.deepEqual(moment(new Date(2010, 1, 14, 15, 25, 50, 125)), moment([2010, 1, 14, 15, 25, 50, 125]), "constructing with array === constructing with new Date()"); test.done(); }, "number" : function(test) { test.expect(2); - test.ok(moment(1000).native() instanceof Date, "1000"); + test.ok(moment(1000).toDate() instanceof Date, "1000"); test.ok((moment(1000).valueOf() === 1000), "testing valueOf"); test.done(); }, "date" : function(test) { test.expect(1); - test.ok(moment(new Date()).native() instanceof Date, "new Date()"); + test.ok(moment(new Date()).toDate() instanceof Date, "new Date()"); test.done(); }, "moment" : function(test) { test.expect(2); - test.ok(moment(moment()).native() instanceof Date, "moment(moment())"); - test.ok(moment(moment(moment())).native() instanceof Date, "moment(moment(moment()))"); + test.ok(moment(moment()).toDate() instanceof Date, "moment(moment())"); + test.ok(moment(moment(moment())).toDate() instanceof Date, "moment(moment(moment()))"); test.done(); }, "undefined" : function(test) { test.expect(1); - test.ok(moment().native() instanceof Date, "undefined"); + test.ok(moment().toDate() instanceof Date, "undefined"); test.done(); }, "string without format" : function(test) { test.expect(2); - test.ok(moment("Aug 9, 1995").native() instanceof Date, "Aug 9, 1995"); - test.ok(moment("Mon, 25 Dec 1995 13:30:00 GMT").native() instanceof Date, "Mon, 25 Dec 1995 13:30:00 GMT"); + test.ok(moment("Aug 9, 1995").toDate() instanceof Date, "Aug 9, 1995"); + test.ok(moment("Mon, 25 Dec 1995 13:30:00 GMT").toDate() instanceof Date, "Mon, 25 Dec 1995 13:30:00 GMT"); test.done(); }, @@ -101,14 +101,14 @@ exports.create = { "string with format (timezone)" : function(test) { test.expect(8); - test.equal(moment('5 -0700', 'H ZZ').native().getUTCHours(), 12, 'parse hours "5 -0700" ---> "H ZZ"'); - test.equal(moment('5 -07:00', 'H Z').native().getUTCHours(), 12, 'parse hours "5 -07:00" ---> "H Z"'); - test.equal(moment('5 -0730', 'H ZZ').native().getUTCMinutes(), 30, 'parse hours "5 -0730" ---> "H ZZ"'); - test.equal(moment('5 -07:30', 'H Z').native().getUTCMinutes(), 30, 'parse hours "5 -07:30" ---> "H Z"'); - test.equal(moment('5 +0100', 'H ZZ').native().getUTCHours(), 4, 'parse hours "5 +0100" ---> "H ZZ"'); - test.equal(moment('5 +01:00', 'H Z').native().getUTCHours(), 4, 'parse hours "5 +01:00" ---> "H Z"'); - test.equal(moment('5 +0130', 'H ZZ').native().getUTCMinutes(), 30, 'parse hours "5 +0130" ---> "H ZZ"'); - test.equal(moment('5 +01:30', 'H Z').native().getUTCMinutes(), 30, 'parse hours "5 +01:30" ---> "H Z"'); + test.equal(moment('5 -0700', 'H ZZ').toDate().getUTCHours(), 12, 'parse hours "5 -0700" ---> "H ZZ"'); + test.equal(moment('5 -07:00', 'H Z').toDate().getUTCHours(), 12, 'parse hours "5 -07:00" ---> "H Z"'); + test.equal(moment('5 -0730', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours "5 -0730" ---> "H ZZ"'); + test.equal(moment('5 -07:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours "5 -07:30" ---> "H Z"'); + test.equal(moment('5 +0100', 'H ZZ').toDate().getUTCHours(), 4, 'parse hours "5 +0100" ---> "H ZZ"'); + test.equal(moment('5 +01:00', 'H Z').toDate().getUTCHours(), 4, 'parse hours "5 +01:00" ---> "H Z"'); + test.equal(moment('5 +0130', 'H ZZ').toDate().getUTCMinutes(), 30, 'parse hours "5 +0130" ---> "H ZZ"'); + test.equal(moment('5 +01:30', 'H Z').toDate().getUTCMinutes(), 30, 'parse hours "5 +01:30" ---> "H Z"'); test.done(); }, diff --git a/test/moment/is_moment.js b/test/moment/is_moment.js index d1f405c50..9b085cc1d 100644 --- a/test/moment/is_moment.js +++ b/test/moment/is_moment.js @@ -5,7 +5,7 @@ exports.is_moment = { test.expect(11); var MyObj = function() {}; - MyObj.prototype.native = function() { + MyObj.prototype.toDate = function() { return new Date(); }