From 06ad3301e6b95fb86209373bb5b2ad4a8f8978e4 Mon Sep 17 00:00:00 2001 From: Jaya Prakash Date: Mon, 1 Sep 2014 06:59:05 +0000 Subject: [PATCH 1/3] Added a test case for the scenario for which dust-helper-intl is not working --- tests/helpers.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/helpers.js b/tests/helpers.js index 2c2306e..3378cce 100644 --- a/tests/helpers.js +++ b/tests/helpers.js @@ -600,6 +600,17 @@ describe('Helper `formatDate`', function () { }); }); + it('should return a formatted string of date and time', function () { + var tmpl = '{@intlDate val="' + timeStamp + '" locales="en-US" month="long" day="2-digit" year="numeric" hour="numeric" minute="numeric" timeZone="UTC"/}', + ctx = {}, + expected = 'January 23 2014 11:00 PM', + d = new Date(timeStamp); + console.log(tmpl); + Dust.renderSource(tmpl, ctx, function(err, out) { + expect(out).to.equal(expected); + }); + }); + it('should return a formatted string of just the time using different locales', function () { var tmpl = '{@formatDate val=' + timeStamp + ' hour="numeric" minute="numeric" timeZone="UTC" locales="de-DE"/}', ctx = {}, From 85b34bdd53936bc150668ddf496a567ec043c485 Mon Sep 17 00:00:00 2001 From: Jaya Prakash Date: Mon, 1 Sep 2014 09:11:59 +0000 Subject: [PATCH 2/3] Replaced with '@intlDate' with '@formatDate' as '@intlDate' is deprecated --- tests/helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/helpers.js b/tests/helpers.js index 3378cce..26b847e 100644 --- a/tests/helpers.js +++ b/tests/helpers.js @@ -601,7 +601,7 @@ describe('Helper `formatDate`', function () { }); it('should return a formatted string of date and time', function () { - var tmpl = '{@intlDate val="' + timeStamp + '" locales="en-US" month="long" day="2-digit" year="numeric" hour="numeric" minute="numeric" timeZone="UTC"/}', + var tmpl = '{@formatDate val="' + timeStamp + '" locales="en-US" month="long" day="2-digit" year="numeric" hour="numeric" minute="numeric" timeZone="UTC"/}', ctx = {}, expected = 'January 23 2014 11:00 PM', d = new Date(timeStamp); From 15786417625a1046ae4fb2a6b9f52e48c4a24171 Mon Sep 17 00:00:00 2001 From: Jaya Prakash Date: Tue, 2 Sep 2014 05:45:40 +0000 Subject: [PATCH 3/3] Added new test case for testing the scenario when timestamp is passed as number for @formatDate helper --- tests/helpers.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/helpers.js b/tests/helpers.js index 26b847e..03faf1f 100644 --- a/tests/helpers.js +++ b/tests/helpers.js @@ -600,12 +600,21 @@ describe('Helper `formatDate`', function () { }); }); - it('should return a formatted string of date and time', function () { + it('should return a formatted string of date and time when timestamp is passed as string', function () { var tmpl = '{@formatDate val="' + timeStamp + '" locales="en-US" month="long" day="2-digit" year="numeric" hour="numeric" minute="numeric" timeZone="UTC"/}', ctx = {}, expected = 'January 23 2014 11:00 PM', d = new Date(timeStamp); - console.log(tmpl); + Dust.renderSource(tmpl, ctx, function(err, out) { + expect(out).to.equal(expected); + }); + }); + + it('should return a formatted string of date and time when timestamp is passed as number', function () { + var tmpl = '{@formatDate val=' + timeStamp + ' locales="en-US" month="long" day="2-digit" year="numeric" hour="numeric" minute="numeric" timeZone="UTC"/}', + ctx = {}, + expected = 'January 23 2014 11:00 PM', + d = new Date(timeStamp); Dust.renderSource(tmpl, ctx, function(err, out) { expect(out).to.equal(expected); });