From: Tim Wood Date: Tue, 15 Jan 2013 20:12:41 +0000 (-0800) Subject: adding more tests for reversed args X-Git-Tag: 2.0.0~18^2^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F579%2Fhead;p=thirdparty%2Fmoment.git adding more tests for reversed args --- diff --git a/test/moment/add_subtract.js b/test/moment/add_subtract.js index 08f6e1fb3..0128b6a91 100644 --- a/test/moment/add_subtract.js +++ b/test/moment/add_subtract.js @@ -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();