]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
adding more tests for reversed args 579/head
authorTim Wood <washwithcare@gmail.com>
Tue, 15 Jan 2013 20:12:41 +0000 (12:12 -0800)
committerTim Wood <washwithcare@gmail.com>
Tue, 15 Jan 2013 20:12:41 +0000 (12:12 -0800)
test/moment/add_subtract.js

index 08f6e1fb38a5f81446bb53ad5ee294552ffaece7..0128b6a915aac5b692948b49c045fefbe9268b32 100644 (file)
@@ -1,7 +1,7 @@
 var moment = require("../../moment");
 
-exports.add_subtract = {
-    "add and subtract short" : function(test) {
+exports.add = {
+    "add short" : function(test) {
         test.expect(12);
 
         var a = moment();
@@ -32,7 +32,7 @@ exports.add_subtract = {
         test.done();
     },
 
-    "add and subtract long" : function(test) {
+    "add long" : function(test) {
         test.expect(8);
 
         var a = moment();
@@ -55,7 +55,7 @@ exports.add_subtract = {
         test.done();
     },
 
-    "add and subtract long singular" : function(test) {
+    "add long singular" : function(test) {
         test.expect(8);
 
         var a = moment();
@@ -78,7 +78,7 @@ exports.add_subtract = {
         test.done();
     },
 
-    "add and subtract string long" : function(test) {
+    "add string long" : function(test) {
         test.expect(9);
 
         var a = moment();
@@ -104,7 +104,7 @@ exports.add_subtract = {
         test.done();
     },
 
-    "add and subtract string long singular" : function(test) {
+    "add string long singular" : function(test) {
         test.expect(9);
 
         var a = moment();
@@ -130,7 +130,7 @@ exports.add_subtract = {
         test.done();
     },
 
-    "add and subtract string short" : function(test) {
+    "add string short" : function(test) {
         test.expect(8);
 
         var a = moment();
@@ -153,7 +153,53 @@ exports.add_subtract = {
         test.done();
     },
 
-    "add and subtract string short reverse args" : function(test) {
+    "add string long reverse args" : function(test) {
+        test.expect(8);
+
+        var a = moment();
+        a.year(2011);
+        a.month(9);
+        a.date(12);
+        a.hours(6);
+        a.minutes(7);
+        a.seconds(8);
+        a.milliseconds(500);
+
+        test.equal(a.add(50, 'millisecond').milliseconds(), 550, 'Add milliseconds');
+        test.equal(a.add(1, 'second', 1).seconds(), 9, 'Add seconds');
+        test.equal(a.add(1, 'minute', 1).minutes(), 8, 'Add minutes');
+        test.equal(a.add(1, 'hour', 1).hours(), 7, 'Add hours');
+        test.equal(a.add(1, 'day', 1).date(), 13, 'Add date');
+        test.equal(a.add(1, 'week', 1).date(), 20, 'Add week');
+        test.equal(a.add(1, 'month', 1).month(), 10, 'Add month');
+        test.equal(a.add(1, 'year', 1).year(), 2012, 'Add year');
+        test.done();
+    },
+
+    "add string long singular reverse args" : function(test) {
+        test.expect(8);
+
+        var a = moment();
+        a.year(2011);
+        a.month(9);
+        a.date(12);
+        a.hours(6);
+        a.minutes(7);
+        a.seconds(8);
+        a.milliseconds(500);
+
+        test.equal(a.add(50, 'milliseconds').milliseconds(), 550, 'Add milliseconds');
+        test.equal(a.add(1, 'seconds').seconds(), 9, 'Add seconds');
+        test.equal(a.add(1, 'minutes').minutes(), 8, 'Add minutes');
+        test.equal(a.add(1, 'hours').hours(), 7, 'Add hours');
+        test.equal(a.add(1, 'days').date(), 13, 'Add date');
+        test.equal(a.add(1, 'weeks').date(), 20, 'Add week');
+        test.equal(a.add(1, 'months').month(), 10, 'Add month');
+        test.equal(a.add(1, 'years').year(), 2012, 'Add year');
+        test.done();
+    },
+
+    "add string short reverse args" : function(test) {
         test.expect(8);
 
         var a = moment();