From: Tim Wood Date: Fri, 8 Mar 2013 18:29:33 +0000 (-0800) Subject: adding zone tests for isSame, isBefore, and isAfter X-Git-Tag: 2.1.0~32^2~2^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb9cb7cbc28bb3b2e700b1717d740a238a88985b;p=thirdparty%2Fmoment.git adding zone tests for isSame, isBefore, and isAfter --- diff --git a/test/moment/zones.js b/test/moment/zones.js index 88876803d..473893f87 100644 --- a/test/moment/zones.js +++ b/test/moment/zones.js @@ -247,6 +247,36 @@ exports.zones = { test.equal(+zoneA, +zoneC, "moment#toDate should output a date with the right unix timestamp"); test.equal(+zoneA, +zoneD, "moment#toDate should output a date with the right unix timestamp"); + test.done(); + }, + + "same / before / after" : function (test) { + var zoneA = moment(), + zoneB = moment(zoneA).zone(120), + zoneC = moment(zoneA).zone(-120); + + test.ok(zoneA.isSame(zoneB), "two moments with different offsets should be the same"); + test.ok(zoneA.isSame(zoneC), "two moments with different offsets should be the same"); + + test.ok(zoneA.isSame(zoneB, 'hour'), "two moments with different offsets should be the same hour"); + test.ok(zoneA.isSame(zoneC, 'hour'), "two moments with different offsets should be the same hour"); + + zoneA.add('hour', 1); + + test.ok(zoneA.isAfter(zoneB), "isAfter should work with two moments with different offsets"); + test.ok(zoneA.isAfter(zoneC), "isAfter should work with two moments with different offsets"); + + test.ok(zoneA.isAfter(zoneB, 'hour'), "isAfter:hour should work with two moments with different offsets"); + test.ok(zoneA.isAfter(zoneC, 'hour'), "isAfter:hour should work with two moments with different offsets"); + + zoneA.subtract('hour', 2); + + test.ok(zoneA.isBefore(zoneB), "isBefore should work with two moments with different offsets"); + test.ok(zoneA.isBefore(zoneC), "isBefore should work with two moments with different offsets"); + + test.ok(zoneA.isBefore(zoneB, 'hour'), "isBefore:hour should work with two moments with different offsets"); + test.ok(zoneA.isBefore(zoneC, 'hour'), "isBefore:hour should work with two moments with different offsets"); + test.done(); }