From ccbf5c43a954a2f890f9135f671f007de21c86aa Mon Sep 17 00:00:00 2001 From: rafael lisboa Date: Thu, 9 Apr 2015 15:29:42 -0300 Subject: refactor mail item mixin creation and rendering --- web-ui/test/spec/helpers/view_helper.spec.js | 20 ++++++++++++-------- .../ui/mail_items/generic_mail_item.spec.js | 2 +- .../spec/mail_list/ui/mail_items/mail_item.spec.js | 1 - 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'web-ui/test/spec') diff --git a/web-ui/test/spec/helpers/view_helper.spec.js b/web-ui/test/spec/helpers/view_helper.spec.js index 920709b2..9729ffb8 100644 --- a/web-ui/test/spec/helpers/view_helper.spec.js +++ b/web-ui/test/spec/helpers/view_helper.spec.js @@ -25,25 +25,29 @@ define(['helpers/view_helper'], function (viewHelper) { }); }); - 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'); }); }); diff --git a/web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js b/web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js index 88735302..87d38595 100644 --- a/web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js +++ b/web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js @@ -7,11 +7,11 @@ describeComponent('mail_list/ui/mail_items/generic_mail_item', function () { mail = Pixelated.testData().parsedMail.simpleTextPlain; mail.tags = []; mail.mailbox = 'inbox'; + mail.currentTag = 'inbox'; this.setupComponent('
  • ', { mail: mail, selected: false, - tag: 'inbox', templateType: 'single' }); }); diff --git a/web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js b/web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js index b1ac3037..03f95e54 100644 --- a/web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js +++ b/web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js @@ -10,7 +10,6 @@ describeMixin('mail_list/ui/mail_items/mail_item', function () { selected: false, tag: 'inbox' }); - this.component.attachListeners(); }); describe('mail checkbox', function () { -- cgit v1.2.3