diff options
Diffstat (limited to 'web-ui')
| -rw-r--r-- | web-ui/app/js/mail_list/ui/mail_items/draft_item.js | 6 | ||||
| -rw-r--r-- | web-ui/app/js/mail_list/ui/mail_items/sent_item.js | 8 | ||||
| -rw-r--r-- | web-ui/test/spec/mail_list/ui/mail_items/draft_item.spec.js | 32 | ||||
| -rw-r--r-- | web-ui/test/test_data.js | 35 | 
4 files changed, 73 insertions, 8 deletions
| diff --git a/web-ui/app/js/mail_list/ui/mail_items/draft_item.js b/web-ui/app/js/mail_list/ui/mail_items/draft_item.js index 4c4b2524..57fbafd5 100644 --- a/web-ui/app/js/mail_list/ui/mail_items/draft_item.js +++ b/web-ui/app/js/mail_list/ui/mail_items/draft_item.js @@ -33,9 +33,9 @@ define(          if (this.isOpeningOnANewTab(ev)) {            return;          } -        this.trigger(document, events.dispatchers.rightPane.openDraft, { ident: this.attr.ident }); -        this.trigger(document, events.ui.mail.updateSelected, { ident: this.attr.ident }); -        this.trigger(document, events.router.pushState, { mailIdent: this.attr.ident }); +        this.trigger(document, events.dispatchers.rightPane.openDraft, { ident: this.attr.mail.ident }); +        this.trigger(document, events.ui.mail.updateSelected, { ident: this.attr.mail.ident }); +        this.trigger(document, events.router.pushState, { mailIdent: this.attr.mail.ident });          ev.preventDefault(); // don't let the hashchange trigger a popstate        }; diff --git a/web-ui/app/js/mail_list/ui/mail_items/sent_item.js b/web-ui/app/js/mail_list/ui/mail_items/sent_item.js index 6ab990dd..9e511068 100644 --- a/web-ui/app/js/mail_list/ui/mail_items/sent_item.js +++ b/web-ui/app/js/mail_list/ui/mail_items/sent_item.js @@ -32,16 +32,16 @@ define(          if (this.isOpeningOnANewTab(ev)) {            return;          } -        this.trigger(document, events.ui.mail.open, { ident: this.attr.ident }); -        this.trigger(document, events.router.pushState, { mailIdent: this.attr.ident }); +        this.trigger(document, events.ui.mail.open, { ident: this.attr.mail.ident }); +        this.trigger(document, events.router.pushState, { mailIdent: this.attr.mail.ident });          ev.preventDefault(); // don't let the hashchange trigger a popstate        };        this.openMail = function (ev, data) { -        if (data.ident !== this.attr.ident) { +        if (data.ident !== this.attr.mail.ident) {            return;          } -        this.trigger(document, events.ui.mail.updateSelected, { ident: this.attr.ident }); +        this.trigger(document, events.ui.mail.updateSelected, { ident: this.attr.mail.ident });        };        this.after('initialize', function () { 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/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      }    }; | 
