diff options
Diffstat (limited to 'web-ui/test/spec/helpers')
-rw-r--r-- | web-ui/test/spec/helpers/view_helper.spec.js | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/web-ui/test/spec/helpers/view_helper.spec.js b/web-ui/test/spec/helpers/view_helper.spec.js index 888c6cda..655ba181 100644 --- a/web-ui/test/spec/helpers/view_helper.spec.js +++ b/web-ui/test/spec/helpers/view_helper.spec.js @@ -9,41 +9,45 @@ define(['helpers/view_helper'], function (viewHelper) { describe('quote email', function() { it('should add > to body text', function() { - testData.rawMail.mail.textPlainBody = 'First Line\nSecond Line'; + testData.parsedMail.simpleTextPlain.textPlainBody = 'First Line\nSecond Line'; - var quotedMail = viewHelper.quoteMail(testData.rawMail.mail); + var quotedMail = viewHelper.quoteMail(testData.parsedMail.simpleTextPlain); expect(quotedMail).toContain('> First Line\n> Second Line'); }); it('should add the mail sender information', function() { - testData.rawMail.mail.textPlainBody = 'First Line\nSecond Line'; + testData.parsedMail.simpleTextPlain.textPlainBody = 'First Line\nSecond Line'; - var quotedMail = viewHelper.quoteMail(testData.rawMail.mail); + var quotedMail = viewHelper.quoteMail(testData.parsedMail.simpleTextPlain); - expect(quotedMail).toContain('On Wed Jun 04 2014 17:41:13 GMT+0000 (UTC), <laurel@hamill.info> wrote'); + expect(quotedMail).toContain('<laurel@hamill.info>'); }); }); - describe('getFormmattedDate', function() { + describe('formatDate', function() { + var template; + beforeEach(function () { + template = Handlebars.compile('{{formatDate date}}'); + }); + it('formats correctly a Date for today', function() { var d = new Date(); - var dtest = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 14, 2, 36); - - var res = viewHelper.getFormattedDate(dtest); + var mailDate = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 14, 2, 36); - expect(res).toEqual('14:02'); + var result = template({ date: mailDate.toISOString() }); + expect(result).toEqual('14:02'); }); it('formats correctly a Date for a specific day', function() { - var dtest = new Date(2013, 2, 13, 7, 56, 1); + var mailDate = new Date(2013, 2, 13, 7, 56, 1); - var res = viewHelper.getFormattedDate(dtest); + var result = template({ date: mailDate.toISOString() }); // This expectation is weird for the month - JS Dates have date numbers be zero-indexed, thus the discrepancy // Specifically, the 2 in the constructor DOES match the 3 in the expectation below. - expect(res).toEqual('2013-03-13'); + expect(result).toEqual('2013-03-13'); }); }); |