From: Iskren Chernev Date: Mon, 16 Sep 2013 11:09:01 +0000 (-0700) Subject: Added more tests X-Git-Tag: 2.3.0~28^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20d19dfb0347b2903b5c09452464261eb87f81b1;p=thirdparty%2Fmoment.git Added more tests --- diff --git a/test/moment/create.js b/test/moment/create.js index 5d806cedd..62c922c8d 100644 --- a/test/moment/create.js +++ b/test/moment/create.js @@ -492,11 +492,20 @@ exports.create = { }, "strict parsing" : function(test) { - test.expect(4); + test.expect(10); test.equal(moment("2012-05", "YYYY-MM", true).format("YYYY-MM"), "2012-05", "parse correct string"); test.equal(moment(" 2012-05", "YYYY-MM", true).isValid(), false, "fail on extra whitespace"); test.equal(moment("foo 2012-05", "[foo] YYYY-MM", true).format('YYYY-MM'), "2012-05", "handle fixed text"); test.equal(moment("2012 05", "YYYY-MM", true).isValid(), false, "fail on different separator"); + + test.equal(moment("05 30 2010", ["DD MM YYYY", "MM DD YYYY"], true).format("MM DD YYYY"), "05 30 2010", "array with bad date"); + test.equal(moment("05 30 2010", ["", "MM DD YYYY"], true).format("MM DD YYYY"), "05 30 2010", "array with invalid format"); + test.equal(moment("05 30 2010", [" DD MM YYYY", "MM DD YYYY"], true).format("MM DD YYYY"), "05 30 2010", "array with non-matching format"); + + test.equal(moment("2010.*...", "YYYY.*", true).isValid(), false, "invalid format with regex chars"); + test.equal(moment("2010.*", "YYYY.*", true).year(), 2010, "valid format with regex chars"); + test.equal(moment(".*2010.*", ".*YYYY.*", true).year(), 2010, "valid format with regex chars on both sides"); + test.done(); },