]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
tests for invalid date string
authorIsaac Cambron <isaac@isaaccambron.com>
Fri, 27 Sep 2013 23:12:42 +0000 (19:12 -0400)
committerIsaac Cambron <isaac@isaaccambron.com>
Fri, 27 Sep 2013 23:12:42 +0000 (19:12 -0400)
test/moment/format.js
test/moment/lang.js

index bf1e32f917ac77dd55fba99422e829722b2ea635..6f0ad681dbe17359d0daf97907a926021ce8000b 100644 (file)
@@ -98,7 +98,7 @@ exports.format = {
 
         m = moment(1234567890.123, 'X');
         test.equals(m.format('X'), '1234567890', 'unix timestamp as integer');
-        
+
         test.done();
     },
 
@@ -325,6 +325,15 @@ exports.format = {
         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();
+    },
+
+    "invalid" : function (test) {
+        moment.lang('en');
+
+        test.equal(moment.invalid().format(), "Invalid date");
+        test.equal(moment.invalid().format('YYYY-MM-DD'), "Invalid date");
+
         test.done();
     }
 };
index 74942171a5559155ba8f047388cac95261e58ea7..05cfca5106f188cb691ab5c9e19cc8a10405681c 100644 (file)
@@ -237,6 +237,17 @@ exports.lang = {
         test.equal(moment('2012-01-01 3b', 'YYYY-MM-DD ha').hour(), 15, 'Custom parsing of meridiem should work');
         test.equal(moment('2012-01-01 3d', 'YYYY-MM-DD ha').hour(), 3, 'Custom parsing of meridiem should work');
 
+        test.done();
+    },
+
+    "invalid date formatting" : function (test) {
+        moment.lang('has-invalid', {
+            invalidDate: 'KHAAAAAAAAAAAN!'
+        });
+
+        test.equal(moment.invalid().format(), "KHAAAAAAAAAAAN!");
+        test.equal(moment.invalid().format('YYYY-MM-DD'), "KHAAAAAAAAAAAN!");
+
         test.done();
     }
 };