Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,26 @@ describe('Helper `formatDate`', 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);
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason we are getting undefined here. I wonder what's going on!

});
});

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 = {},
Expand Down