]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Switching to toDate instead of native in all the tests
authorTim Wood <washwithcare@gmail.com>
Wed, 21 Mar 2012 17:29:40 +0000 (10:29 -0700)
committerTim Wood <washwithcare@gmail.com>
Wed, 21 Mar 2012 17:29:40 +0000 (10:29 -0700)
#216 #211

test/moment/create.js
test/moment/is_moment.js

index 3a68557e9dc4837374531f2e399c56b2485f4f1e..ab02344c4c63e4d413fdfc2685675bf08fcb4a74 100644 (file)
@@ -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();
     },
 
index d1f405c50e1f4f750e5f7b960e7c61d0e950d46f..9b085cc1d463d7ea45458a14b18060fedcb51ef2 100644 (file)
@@ -5,7 +5,7 @@ exports.is_moment = {
         test.expect(11);
 
         var MyObj = function() {};
-        MyObj.prototype.native = function() {
+        MyObj.prototype.toDate = function() {
             return new Date();
         }