From: Simon Bernier St-Pierre Date: Tue, 3 Jun 2014 16:59:54 +0000 (-0400) Subject: Add more relevant tests. X-Git-Tag: 2.7.0~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18393c1c6ed97807779e48cae2bfdddbd110d744;p=thirdparty%2Fmoment.git Add more relevant tests. I've added much more relevant tests, checking the _f property for the format that was used for parsing and _pf.iso in the case of ISO. --- diff --git a/test/moment/create.js b/test/moment/create.js index 58dd77626..e81eedb23 100644 --- a/test/moment/create.js +++ b/test/moment/create.js @@ -397,11 +397,12 @@ exports.create = { // pass an ISO date in the array of formats function parseISO(string) { - return moment(string, ['YYYY', 'HH:mm', 'M', moment.ISO_8601]); + return moment(string, [moment.ISO_8601, 'MM', 'HH:mm', 'YYYY']); } - test.equal(parseISO('1994').year(), 1994, 'iso: test parse year'); - test.equal(parseISO('17:15').format('HH:mm'), '17:15', 'iso: test parse HH:mm'); - test.equal(parseISO('2012-06-01').format('YYYY-MM-DD'), '2012-06-01', 'iso: test parse iso'); + test.equal(parseISO('1994')._f, 'YYYY', 'iso: test parse YYYY'); + test.equal(parseISO('17:15')._f, 'HH:mm', 'iso: test parse HH:mm'); + test.equal(parseISO('06')._f, 'MM', 'iso: test parse MM'); + test.equal(parseISO('2012-06-01')._pf.iso, true, 'iso: test parse iso'); test.equal(moment('2014-05-05', [moment.ISO_8601, 'YYYY-MM-DD'])._pf.iso, true, 'iso: edge case array precedence iso'); test.equal(moment('2014-05-05', ['YYYY-MM-DD', moment.ISO_8601])._pf.iso, false, 'iso: edge case array precedence not iso');