diff options
Diffstat (limited to 'web-ui/test')
-rw-r--r-- | web-ui/test/spec/helpers/view_helper.spec.js | 30 | ||||
-rw-r--r-- | web-ui/test/spec/mail_list/ui/mail_items/draft_item.spec.js | 32 | ||||
-rw-r--r-- | web-ui/test/spec/mail_list/ui/mail_items/generic_mail_item.spec.js | 2 | ||||
-rw-r--r-- | web-ui/test/spec/mail_list/ui/mail_items/mail_item.spec.js | 8 | ||||
-rw-r--r-- | web-ui/test/spec/mail_view/ui/send_button.spec.js | 16 | ||||
-rw-r--r-- | web-ui/test/spec/mixins/with_mail_edit_base.spec.js | 4 | ||||
-rw-r--r-- | web-ui/test/spec/tags/ui/tag_list.spec.js | 7 | ||||
-rw-r--r-- | web-ui/test/test_data.js | 35 |
8 files changed, 102 insertions, 32 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'); }); }); 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 058040c9..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 @@ -20,6 +20,14 @@ describeMixin('mail_list/ui/mail_items/mail_item', function () { checkbox = this.component.$node.find('input[type=checkbox]'); }); + it('unchecks itself when another tag is selected', function () { + this.component.checkCheckbox(); + this.component.trigger(document, Pixelated.events.ui.tag.select, { tag: 'amazing'}); + + expect(mailUncheckedEvent).toHaveBeenTriggeredOn(document); + expect(checkbox.prop('checked')).toBe(false); + }); + it('checkCheckbox checks it and triggers events.ui.mail.checked', function () { this.component.checkCheckbox(); diff --git a/web-ui/test/spec/mail_view/ui/send_button.spec.js b/web-ui/test/spec/mail_view/ui/send_button.spec.js index 17de1531..351b4a08 100644 --- a/web-ui/test/spec/mail_view/ui/send_button.spec.js +++ b/web-ui/test/spec/mail_view/ui/send_button.spec.js @@ -25,6 +25,14 @@ describeComponent('mail_view/ui/send_button', function () { expect(this.$node).not.toBeDisabled(); }); + + it('gets enabled if recipients:updated also with invalid email', function () { + $(document).trigger(Pixelated.events.ui.recipients.inputFieldHasCharacters, { name: 'to' }); + $(document).trigger(Pixelated.events.ui.recipients.updated, { newRecipients: ['InvalidEmail']}); + + expect(this.$node).not.toBeDisabled(); + expect(this.$node.text()).toBe('Send'); + }); }); describe('multiple events', function () { @@ -63,14 +71,6 @@ describeComponent('mail_view/ui/send_button', function () { expect(this.$node).toBeDisabled(); }); - - it('gets disabled if recipients:updated with invalid email', function () { - $(document).trigger(Pixelated.events.ui.recipients.inputFieldHasCharacters, { name: 'to' }); - $(document).trigger(Pixelated.events.ui.recipients.updated, { newRecipients: ['InvalidEmail']}); - - expect(this.$node).not.toBeDisabled(); - expect(this.$node.text()).toBe('Send'); - }); }); describe('on click', function () { diff --git a/web-ui/test/spec/mixins/with_mail_edit_base.spec.js b/web-ui/test/spec/mixins/with_mail_edit_base.spec.js index 8f495399..940b4b5e 100644 --- a/web-ui/test/spec/mixins/with_mail_edit_base.spec.js +++ b/web-ui/test/spec/mixins/with_mail_edit_base.spec.js @@ -18,8 +18,8 @@ describeMixin('mixins/with_mail_edit_base', function () { recipients: { to: ['foobar@mail.com'], cc: [] } }); - expect(recipientsUpdatedEvent).toHaveBeenTriggeredOnAndWith(document, { newRecipients: ['foobar@mail.com'], name: 'to'}); - expect(recipientsUpdatedEvent).not.toHaveBeenTriggeredOnAndWith(document, { newRecipients: [], name: 'cc'}); + expect(recipientsUpdatedEvent).toHaveBeenTriggeredOnAndWith(document, { newRecipients: ['foobar@mail.com'], recipientsName: 'to'}); + expect(recipientsUpdatedEvent).not.toHaveBeenTriggeredOnAndWith(document, { newRecipients: [], recipientsName: 'cc'}); }); }); diff --git a/web-ui/test/spec/tags/ui/tag_list.spec.js b/web-ui/test/spec/tags/ui/tag_list.spec.js index e84c68aa..f92f72af 100644 --- a/web-ui/test/spec/tags/ui/tag_list.spec.js +++ b/web-ui/test/spec/tags/ui/tag_list.spec.js @@ -62,13 +62,6 @@ describeComponent('tags/ui/tag_list', function () { expect(this.component.attr.currentTag).toEqual('amazing'); }); - it('should uncheck all emails when a new tag is selected', function () { - var uncheckAllEvent = spyOnEvent(document, Pixelated.events.ui.mails.uncheckAll); - $(document).trigger(Pixelated.events.ui.tag.select, { tag: 'amazing'}); - - expect(uncheckAllEvent).toHaveBeenTriggeredOn(document); - }); - it('resets the tag lists when loading tags', function () { var tagList = [tag('tag1', 1, false), tag('tag2', 2, true), tag('tag3', 3, true)]; $(document).trigger(Pixelated.events.tags.received, {tags: tagList}); diff --git a/web-ui/test/test_data.js b/web-ui/test/test_data.js index f09260c9..446fd7c6 100644 --- a/web-ui/test/test_data.js +++ b/web-ui/test/test_data.js @@ -170,6 +170,38 @@ define(function() { } }; + var draftMail = { + status: [], + header: {'from': 'jed_waelchi@cummerata.info', + cc: [], + bcc: [], + to: [], + date: '2015-04-09T18:30:18.998999-03:00', + subject: 'bla'}, + ident: 'B2432', + replying: {'single': 'jed_waelchi@cummerata.info', + all: { + 'to-field': ['jed_waelchi@cummerata.info'], + 'cc-field': [] + } + }, + attachments: [], + textPlainBody: 'bla', + tags: [], + htmlBody: null, + mailbox: 'drafts', + security_casing: {'locks': [], + imprints: [{'state': 'no_signature_information'}] + }, + isSentMail: function() { return false; }, + isDraftMail: function() { return false; }, + replyToAddress: function() { return { to: ['jed_waelchi@cummerata.info'], cc: [] }; }, + replyToAllAddress: function() { return { to: ['jed_waelchi@cummerata.info'], cc: [] }; }, + isMailMultipartAlternative: function () { return false; }, + availableBodyPartsContentType: function () { return []; }, + getMailPartByContentType: function () { return; } + }; + var testData = { rawMail: { mail: rawMail, @@ -182,7 +214,8 @@ define(function() { }, parsedMail: { simpleTextPlain: simpleTextPlainMail, - html: htmlNoEncodingMail + html: htmlNoEncodingMail, + draft: draftMail } }; |