]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Add additional .calendar() tests, relocate
authorbentaber <ben.taber@gmail.com>
Mon, 26 Aug 2013 20:00:40 +0000 (14:00 -0600)
committerbentaber <ben.taber@gmail.com>
Mon, 26 Aug 2013 20:00:40 +0000 (14:00 -0600)
test/moment/format.js
test/moment/preparse_postformat.js

index fd0e1e59128202b0e3e26fa2e3e6a6ebb5d5aa79..6fd6d4f3d2f71aedf6ad617f987ebf00eb16eff0 100644 (file)
@@ -307,6 +307,24 @@ exports.format = {
         moment.lang('postformat', {postformat: function (s) { s.replace(/./g, 'X'); }});
         test.equal(moment.utc([2000, 0, 1]).toJSON(), "2000-01-01T00:00:00.000Z", "toJSON doesn't postformat");
         moment.lang('postformat', null);
+        test.done();
+    },
+
+    "calendar day timezone" : function (test) {
+        test.expect(10);
+
+        var zones = [60, -60, 90, -90, 360, -360, 720, -720],
+            b = moment().utc().startOf('day').subtract({ m : 1 }),
+            c = moment().local().startOf('day').subtract({ m : 1 });
+
+        zones.forEach(function(z) {
+            var a = moment().zone(z).startOf('day').subtract({ m: 1 });
+            test.equal(moment(a).zone(z).calendar(), "Yesterday at 11:59 PM", "Yesterday at 11:59 PM, not Today, or the wrong time");
+        });
+
+        test.equal(moment(b).utc().calendar(), "Yesterday at 11:59 PM", "Yesterday at 11:59 PM, not Today, or the wrong time");
+        test.equal(moment(c).local().calendar(), "Yesterday at 11:59 PM", "Yesterday at 11:59 PM, not Today, or the wrong time");
+
         test.done();
     }
 };
index cf969068dd4db8267fd4d029f55e07d2531ba72c..b7dd8f1ce7204fc676677a2c086f751a2cb99c54 100644 (file)
@@ -86,16 +86,6 @@ exports.preparse_postformat = {
         test.equal(moment(a).subtract({ h: 1 }).calendar(),  "Today at !:)) AM",     "Now minus 1 hour");
         test.equal(moment(a).subtract({ d: 1 }).calendar(),  "Yesterday at @:)) AM", "yesterday at the same time");
 
-        test.done();
-    },
-
-    "calendar day timezone" : function (test) {
-        test.expect(1);
-
-        var z = 60,
-            a = moment().zone(z).startOf('day').subtract({ m: 1 });
-
-        test.equal(moment(a).zone(z).calendar(), "Yesterday at !!:%( PM", "Yesterday at 11:59 PM");
         test.done();
     }
 };