From: Tim Wood Date: Mon, 29 Oct 2012 16:32:03 +0000 (-0700) Subject: Failing tests for calling postformat on duration.humanize X-Git-Tag: 2.0.0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccc95eadaf896a4d117a6f782c791f0a7e38f2f0;p=thirdparty%2Fmoment.git Failing tests for calling postformat on duration.humanize #405 --- diff --git a/test/moment/preparse_postformat.js b/test/moment/preparse_postformat.js index 2b1719f21..5e1c8128d 100644 --- a/test/moment/preparse_postformat.js +++ b/test/moment/preparse_postformat.js @@ -50,6 +50,34 @@ exports.preparse_postformat = { test.equal(moment.utc('@)!@-)*-@&').unix(), 1346025600, "preparse ISO8601 string"); test.equal(moment.unix(1346025600).utc().format('YYYY-MM-DD'), '@)!@-)*-@&', "postformat"); + test.done(); + }, + + "transform from": function(test) { + test.expect(3); + moment.lang('symbol', symbolLang); + + var start = moment([2007, 1, 28]); + + test.equal(start.from(moment([2007, 1, 28]).add({s:90}), true), "@ minutes", "postformat should work on moment.fn.from"); + test.equal(moment().add('d', 6).fromNow(true), "^ days", "postformat should work on moment.fn.fromNow"); + test.equal(moment.duration(10, "h").humanize(), "!) hours", "postformat should work on moment.duration.fn.humanize"); + + test.done(); + }, + + "calendar day" : function(test) { + test.expect(6); + moment.lang('symbol', symbolLang); + + var a = moment().hours(2).minutes(0).seconds(0); + + test.equal(moment(a).calendar(), "Today at @:)) AM", "today at the same time"); + test.equal(moment(a).add({ m: 25 }).calendar(), "Today at @:@% AM", "Now plus 25 min"); + test.equal(moment(a).add({ h: 1 }).calendar(), "Today at #:)) AM", "Now plus 1 hour"); + test.equal(moment(a).add({ d: 1 }).calendar(), "Tomorrow at @:)) AM", "tomorrow at the same time"); + 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(); } };