diff options
author | Rafael Lisboa <rafaelzlisboa@gmail.com> | 2015-04-14 16:13:49 -0300 |
---|---|---|
committer | Rafael Lisboa <rafaelzlisboa@gmail.com> | 2015-04-14 16:13:49 -0300 |
commit | f4aa7e41b343704843002ffc8a85c58abf09b911 (patch) | |
tree | 3a8b54edf62fadcb322d0f5cabeecde2c83f3067 /web-ui/test/spec | |
parent | 2ec6d6260c8fcc66446d3e600b70dd0043109744 (diff) | |
parent | 8d2869fa1fa2018772d4f310c4ba9b9c9373a667 (diff) |
Merge pull request #376 from pixelated-project/mail-item-refactor
Mail item refactor
Diffstat (limited to 'web-ui/test/spec')
4 files changed, 45 insertions, 10 deletions
diff --git a/web-ui/test/spec/helpers/view_helper.spec.js b/web-ui/test/spec/helpers/view_helper.spec.js index 920709b2..655ba181 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/draft_item.spec.js b/web-ui/test/spec/mail_list/ui/mail_items/draft_item.spec.js new file mode 100644 index 00000000..fbe285c6 --- /dev/null +++ b/web-ui/test/spec/mail_list/ui/mail_items/draft_item.spec.js @@ -0,0 +1,32 @@ +describeComponent('mail_list/ui/mail_items/draft_item', function () { + 'use strict'; + + var mail; + + beforeEach(function () { + mail = Pixelated.testData().parsedMail.draft; + + this.setupComponent('<li></li>', { + mail: mail, + selected: false, + templateType: 'single' + }); + }); + + it('should de-select the item if a new mail is composed', function () { + this.component.$node.addClass('selected'); + + $(document).trigger(Pixelated.events.ui.composeBox.newMessage); + + expect(this.component.$node).not.toHaveClass('selected'); + }); + + it('should trigger the openDraft event when clicked', function () { + var openDraftEvent = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openDraft); + + this.$node.find('a').click(); + + expect(openDraftEvent).toHaveBeenTriggeredOnAndWith(document, { ident: 'B2432' }); + }); +}); + 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('<li></li>', { 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 () { |