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();
test.done();
},
- "add and subtract long" : function(test) {
+ "add long" : function(test) {
test.expect(8);
var a = moment();
test.done();
},
- "add and subtract long singular" : function(test) {
+ "add long singular" : function(test) {
test.expect(8);
var a = moment();
test.done();
},
- "add and subtract string long" : function(test) {
+ "add string long" : function(test) {
test.expect(9);
var a = moment();
test.done();
},
- "add and subtract string long singular" : function(test) {
+ "add string long singular" : function(test) {
test.expect(9);
var a = moment();
test.done();
},
- "add and subtract string short" : function(test) {
+ "add string short" : function(test) {
test.expect(8);
var a = moment();
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();