diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-10-20 12:17:18 +0200 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-10-20 12:32:06 +0200 |
commit | 495bc391e140cc2bb462c81fa90410a0fe8f6a4c (patch) | |
tree | 5c141e2fcaefd508acf407267bb23807d46710a9 /web-ui/test/spec/mail_view | |
parent | b74a39f27c292cc95345b7ab266bb3db2f812a66 (diff) |
massive update of bower and npm libs - includes flight, jasmine and a bunch of
stuff. If things get weird when developing, remove you bower_components
and your node_modules and install it again
Diffstat (limited to 'web-ui/test/spec/mail_view')
13 files changed, 52 insertions, 53 deletions
diff --git a/web-ui/test/spec/mail_view/data/mail_sender.spec.js b/web-ui/test/spec/mail_view/data/mail_sender.spec.js index f5a0dd92..3f6a2eaa 100644 --- a/web-ui/test/spec/mail_view/data/mail_sender.spec.js +++ b/web-ui/test/spec/mail_view/data/mail_sender.spec.js @@ -9,14 +9,14 @@ describeComponent('mail_view/data/mail_sender', function () { beforeEach(function () { mailBuilder = require('mail_view/data/mail_builder'); mail = Pixelated.testData().parsedMail.simpleTextPlain; - setupComponent(); + this.setupComponent(); }); it('sends mail data with a POST to the server when asked to send email', function() { var mailSentEventSpy = spyOnEvent(document, Pixelated.events.mail.sent); var g; - spyOn($, 'ajax').andReturn({done: function(f) { g = f; return {fail: function(){}};}}); + spyOn($, 'ajax').and.returnValue({done: function(f) { g = f; return {fail: function(){}};}}); this.component.trigger(Pixelated.events.mail.send, mail); @@ -24,17 +24,17 @@ describeComponent('mail_view/data/mail_sender', function () { expect(mailSentEventSpy).toHaveBeenTriggeredOn(document); - expect($.ajax.mostRecentCall.args[0]).toEqual('/mails'); - expect($.ajax.mostRecentCall.args[1].type).toEqual('POST'); - expect(JSON.parse($.ajax.mostRecentCall.args[1].data).header).toEqual(mail.header); - expect(JSON.parse($.ajax.mostRecentCall.args[1].data).body).toEqual(mail.body); + expect($.ajax.calls.mostRecent().args[0]).toEqual('/mails'); + expect($.ajax.calls.mostRecent().args[1].type).toEqual('POST'); + expect(JSON.parse($.ajax.calls.mostRecent().args[1].data).header).toEqual(mail.header); + expect(JSON.parse($.ajax.calls.mostRecent().args[1].data).body).toEqual(mail.body); }); it('save draft data with a PUT to the server', function() { var draftSavedEventSpy = spyOnEvent(document, Pixelated.events.mail.draftSaved); var g; - spyOn($, 'ajax').andReturn({done: function(f) { g = f; return {fail: function(){}};}}); + spyOn($, 'ajax').and.returnValue({done: function(f) { g = f; return {fail: function(){}};}}); mail.ident = 0; this.component.trigger(Pixelated.events.mail.saveDraft, mail); @@ -43,10 +43,10 @@ describeComponent('mail_view/data/mail_sender', function () { expect(draftSavedEventSpy).toHaveBeenTriggeredOn(document); - expect($.ajax.mostRecentCall.args[0]).toEqual('/mails'); - expect($.ajax.mostRecentCall.args[1].type).toEqual('PUT'); - expect(JSON.parse($.ajax.mostRecentCall.args[1].data).header).toEqual(mail.header); - expect(JSON.parse($.ajax.mostRecentCall.args[1].data).body).toEqual(mail.body); + expect($.ajax.calls.mostRecent().args[0]).toEqual('/mails'); + expect($.ajax.calls.mostRecent().args[1].type).toEqual('PUT'); + expect(JSON.parse($.ajax.calls.mostRecent().args[1].data).header).toEqual(mail.header); + expect(JSON.parse($.ajax.calls.mostRecent().args[1].data).body).toEqual(mail.body); }); it('displays generic error message when sending an email fails in the service', function () { @@ -55,7 +55,7 @@ describeComponent('mail_view/data/mail_sender', function () { deferred.reject({responseJSON: {}}, 500, 'Internal Server Error'); var messageEvent = spyOnEvent(document, Pixelated.events.ui.userAlerts.displayMessage); - spyOn($, 'ajax').andReturn(deferred); + spyOn($, 'ajax').and.returnValue(deferred); this.component.trigger(Pixelated.events.mail.send, mail); @@ -68,7 +68,7 @@ describeComponent('mail_view/data/mail_sender', function () { deferred.reject({responseJSON: {message: 'test: error message'}}, 422, 'Unprocessable Entity'); var messageEvent = spyOnEvent(document, Pixelated.events.ui.userAlerts.displayMessage); - spyOn($, 'ajax').andReturn(deferred); + spyOn($, 'ajax').and.returnValue(deferred); this.component.trigger(Pixelated.events.mail.send, mail); diff --git a/web-ui/test/spec/mail_view/ui/compose_box.spec.js b/web-ui/test/spec/mail_view/ui/compose_box.spec.js index f5abac42..d17d4b17 100644 --- a/web-ui/test/spec/mail_view/ui/compose_box.spec.js +++ b/web-ui/test/spec/mail_view/ui/compose_box.spec.js @@ -5,7 +5,7 @@ describeComponent('mail_view/ui/compose_box', function () { 'use strict'; beforeEach(function () { Pixelated.mockBloodhound(); - setupComponent('<div style="display:none"></div>'); + this.setupComponent('<div style="display:none"></div>'); }); diff --git a/web-ui/test/spec/mail_view/ui/draft_box.spec.js b/web-ui/test/spec/mail_view/ui/draft_box.spec.js index 9a93791d..19b264b0 100644 --- a/web-ui/test/spec/mail_view/ui/draft_box.spec.js +++ b/web-ui/test/spec/mail_view/ui/draft_box.spec.js @@ -14,7 +14,7 @@ describeComponent('mail_view/ui/draft_box', function () { it('fetches the email to draft', function () { var mailWantEvent = spyOnEvent(document, Pixelated.events.mail.want); - setupComponent({mailIdent: '1'}); + this.setupComponent({mailIdent: '1'}); expect(mailWantEvent).toHaveBeenTriggeredOnAndWith(document, { mail: '1', caller: this.component @@ -24,7 +24,7 @@ describeComponent('mail_view/ui/draft_box', function () { describe('after initialize', function () { beforeEach(function () { - setupComponent({mailIdent: '1'}); + this.setupComponent({mailIdent: '1'}); }); it('renders the compose box when mail is received', function () { @@ -44,7 +44,7 @@ describeComponent('mail_view/ui/draft_box', function () { }); it('sending a draft sends the correct mailIdent', function () { - setupComponent({mailIdent: mail.ident}); + this.setupComponent({mailIdent: mail.ident}); this.component.trigger(this.component, Pixelated.events.mail.here, { mail: mail}); var sendDraftEvent = spyOnEvent(document, Pixelated.events.mail.saveDraft); @@ -56,7 +56,7 @@ describeComponent('mail_view/ui/draft_box', function () { it('shows no message selected pane when draft is sent', function() { var openNoMessageSelectedEvent = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openNoMessageSelected); - setupComponent({mailIdent: mail.ident}); + this.setupComponent({mailIdent: mail.ident}); this.component.trigger(this.component, Pixelated.events.mail.here, { mail: mail}); this.component.trigger(document, Pixelated.events.mail.sent); diff --git a/web-ui/test/spec/mail_view/ui/draft_save_status.spec.js b/web-ui/test/spec/mail_view/ui/draft_save_status.spec.js index bbcd6b1a..0e428066 100644 --- a/web-ui/test/spec/mail_view/ui/draft_save_status.spec.js +++ b/web-ui/test/spec/mail_view/ui/draft_save_status.spec.js @@ -3,7 +3,7 @@ describeComponent('mail_view/ui/draft_save_status', function () { 'use strict'; - beforeEach(setupComponent); + beforeEach(this.setupComponent); it('should be empty on initialization', function() { expect(this.$node.text()).toBe(''); diff --git a/web-ui/test/spec/mail_view/ui/forward_box.spec.js b/web-ui/test/spec/mail_view/ui/forward_box.spec.js index cba50bc9..30b3b064 100644 --- a/web-ui/test/spec/mail_view/ui/forward_box.spec.js +++ b/web-ui/test/spec/mail_view/ui/forward_box.spec.js @@ -14,7 +14,7 @@ describeComponent('mail_view/ui/forward_box', function () { it('should have a subject of Fwd: <original_message>', function() { testMail.header.subject = 'Very interesting'; - setupComponent({ mail: testMail }); + this.setupComponent({ mail: testMail }); expect(this.component.select('subjectDisplay').text()).toEqual('Fwd: '+ testMail.header.subject); }); @@ -23,25 +23,25 @@ describeComponent('mail_view/ui/forward_box', function () { var Recipients = require('mail_view/ui/recipients/recipients'); spyOn(Recipients, 'attachTo'); - setupComponent({ mail: testMail }); + this.setupComponent({ mail: testMail }); - expect(Recipients.attachTo.calls[0].args[1]).toEqual({name: 'to', addresses: []}); - expect(Recipients.attachTo.calls[1].args[1]).toEqual({name: 'cc', addresses: []}); - expect(Recipients.attachTo.calls[2].args[1]).toEqual({name: 'bcc', addresses: []}); + expect(Recipients.attachTo.calls.all()[0].args[1]).toEqual({name: 'to', addresses: []}); + expect(Recipients.attachTo.calls.all()[1].args[1]).toEqual({name: 'cc', addresses: []}); + expect(Recipients.attachTo.calls.all()[2].args[1]).toEqual({name: 'bcc', addresses: []}); }); it('should populate body text area with quote of email being forwarded', function() { var viewHelper = require('helpers/view_helper'); - spyOn(viewHelper, 'quoteMail').andReturn('quoted email'); + spyOn(viewHelper, 'quoteMail').and.returnValue('quoted email'); - setupComponent({ mail: testMail }); + this.setupComponent({ mail: testMail }); expect(viewHelper.quoteMail).toHaveBeenCalledWith(testMail); expect(this.component.select('bodyBox').val()).toBe('quoted email'); }); it('should show subject field when clicking on subject display', function() { - setupComponent({ mail: testMail }); + this.setupComponent({ mail: testMail }); this.component.select('subjectDisplay').click(); @@ -61,7 +61,7 @@ describeComponent('mail_view/ui/forward_box', function () { testMail.header.sender = 'original_sender'; testMail.header.to = 'original_to@email.com'; - setupComponent({ mail: testMail }); + this.setupComponent({ mail: testMail }); this.component.attr.recipientValues.to.push('forward_to@email.com'); $(document).trigger(Pixelated.events.ui.mail.send); @@ -83,7 +83,7 @@ describeComponent('mail_view/ui/forward_box', function () { it('triggers openMail when email is sent', function() { var eventSpy = spyOnEvent(document, Pixelated.events.ui.mail.open); - setupComponent({ mail: testMail }); + this.setupComponent({ mail: testMail }); $(document).trigger(Pixelated.events.mail.sent, {ident: testMail.ident}); expect(eventSpy).toHaveBeenTriggeredOnAndWith(document, {ident: testMail.ident}); }); diff --git a/web-ui/test/spec/mail_view/ui/mail_actions.spec.js b/web-ui/test/spec/mail_view/ui/mail_actions.spec.js index cee4f689..897726b6 100644 --- a/web-ui/test/spec/mail_view/ui/mail_actions.spec.js +++ b/web-ui/test/spec/mail_view/ui/mail_actions.spec.js @@ -7,7 +7,7 @@ describeComponent('mail_view/ui/mail_actions', function () { beforeEach(function(){ testData = Pixelated.testData(); - setupComponent(testData); + this.setupComponent(testData.rawMail); }); it('verifies if more actions list is hidden when rendering mail view', function() { @@ -48,13 +48,12 @@ describeComponent('mail_view/ui/mail_actions', function () { }); it('triggers a delete event when clicking on delete-button-top', function(){ - var deleteEvent = spyOnEvent(document, Pixelated.events.ui.mail.delete); this.component.select('viewMoreActions').click(); this.component.select('deleteButtonTop').click(); - expect(deleteEvent).toHaveBeenTriggeredOnAndWith(document, {mail: testData.mail}); + expect(deleteEvent).toHaveBeenTriggeredOnAndWith(document, {mail: testData.rawMail.mail}); var moreActionsComponent = this.component.select('moreActions'); expect(moreActionsComponent.attr('style').trim()).toEqual('display: none;'); diff --git a/web-ui/test/spec/mail_view/ui/mail_view.spec.js b/web-ui/test/spec/mail_view/ui/mail_view.spec.js index 9fed8275..1cc7eff0 100644 --- a/web-ui/test/spec/mail_view/ui/mail_view.spec.js +++ b/web-ui/test/spec/mail_view/ui/mail_view.spec.js @@ -11,13 +11,13 @@ describeComponent('mail_view/ui/mail_view', function () { mail = {ident: 1, header: { date: '12/12/12T12:12' }, tags: ['inbox']}; testData = {mail: Pixelated.testData().parsedMail.simpleTextPlain}; Pixelated.mockBloodhound(); - setupComponent('<div></div>', {mail: mail}); + this.setupComponent('<div></div>', {mail: mail}); }); it('triggers mail:want on ui:openMail', function () { var spyEvent = spyOnEvent(document, Pixelated.events.mail.want); - setupComponent('<div></div>', {ident: mail.ident }); + this.setupComponent('<div></div>', {ident: mail.ident }); expect(spyEvent).toHaveBeenTriggeredOn(document); expect(spyEvent.mostRecentCall.data.mail).toEqual(1); @@ -137,25 +137,25 @@ describeComponent('mail_view/ui/mail_view', function () { }); it('shows that mail is encrypted if it is', function() { - spyOn(this.component, 'checkEncrypted').andReturn('encrypted'); + spyOn(this.component, 'checkEncrypted').and.returnValue('encrypted'); this.component.displayMail({}, testData); expect(this.component.$node.find('.encrypted')).toExist(); }); it('shows that mail is signed if it is', function() { - spyOn(this.component, 'checkSigned').andReturn('signed'); + spyOn(this.component, 'checkSigned').and.returnValue('signed'); this.component.displayMail({}, testData); expect(this.component.$node.find('.signed')).toExist(); }); it('shows that mail is not encrypted if it isn\'t', function() { - spyOn(this.component, 'checkEncrypted').andReturn('not-encrypted'); + spyOn(this.component, 'checkEncrypted').and.returnValue('not-encrypted'); this.component.displayMail({}, testData); expect(this.component.$node.find('.not-encrypted')).toExist(); }); it('shows that mail is not signed if it isn\'t', function() { - spyOn(this.component, 'checkEncrypted').andReturn('not-signed'); + spyOn(this.component, 'checkEncrypted').and.returnValue('not-signed'); this.component.displayMail({}, testData); expect(this.component.$node.find('.not-signed')).toExist(); }); diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients.spec.js index 672cf4a3..6aa4589a 100644 --- a/web-ui/test/spec/mail_view/ui/recipients/recipients.spec.js +++ b/web-ui/test/spec/mail_view/ui/recipients/recipients.spec.js @@ -6,21 +6,21 @@ describeComponent('mail_view/ui/recipients/recipients',function () { describe('initialization', function() { it('adds recipients', function() { - setupComponent({name: 'to', addresses: ['foobar@gmail.com'] }); + this.setupComponent({name: 'to', addresses: ['foobar@gmail.com'] }); expect(this.component.attr.recipients.length).toBe(1); }); it('does not trigger recipients updated events on initialization', function() { recipientsUpdatedEvent = spyOnEvent(document, Pixelated.events.ui.recipients.updated); - setupComponent({name: 'to', addresses: ['foobar@gmail.com'] }); + this.setupComponent({name: 'to', addresses: ['foobar@gmail.com'] }); expect(recipientsUpdatedEvent).not.toHaveBeenTriggeredOn(document); }); }); describe('adding recipients from the ui', function() { beforeEach(function () { - setupComponent(); + this.setupComponent(); recipientsUpdatedEvent = spyOnEvent(document, Pixelated.events.ui.recipients.updated); this.component.trigger(Pixelated.events.ui.recipients.entered, {name: 'to', addresses: ['foobar@gmail.com'] }); }); diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js index 56bb1120..499065c2 100644 --- a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js +++ b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js @@ -2,7 +2,7 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { 'use strict'; beforeEach(function () { - setupComponent({name: 'to'}); + this.setupComponent({name: 'to'}); }); describe('keys that finish address input', function () { @@ -42,7 +42,7 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { this.$node.trigger(enterAddressKeyPressEvent); expect(enterAddressKeyPressEvent.preventDefault).toHaveBeenCalled(); - enterAddressKeyPressEvent.preventDefault.reset(); + enterAddressKeyPressEvent.preventDefault.calls.reset(); this.$node.val('anything'); this.$node.trigger(enterAddressKeyPressEvent); expect(enterAddressKeyPressEvent.preventDefault).toHaveBeenCalled(); diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients_iterator.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients_iterator.spec.js index 74e5c614..60ea6526 100644 --- a/web-ui/test/spec/mail_view/ui/recipients/recipients_iterator.spec.js +++ b/web-ui/test/spec/mail_view/ui/recipients/recipients_iterator.spec.js @@ -15,7 +15,7 @@ define(['mail_view/ui/recipients/recipients_iterator'], function (RecipientsIter } function resetMock(m) { - m.destroy.reset();m.select.reset();m.unselect.reset(); + m.destroy.calls.reset();m.select.calls.reset();m.unselect.calls.reset(); } beforeEach(function () { diff --git a/web-ui/test/spec/mail_view/ui/reply_box.spec.js b/web-ui/test/spec/mail_view/ui/reply_box.spec.js index fa229506..c81af683 100644 --- a/web-ui/test/spec/mail_view/ui/reply_box.spec.js +++ b/web-ui/test/spec/mail_view/ui/reply_box.spec.js @@ -9,7 +9,7 @@ describeComponent('mail_view/ui/reply_box', function () { attrs = { mail: Pixelated.testData().parsedMail.simpleTextPlain }; - setupComponent(attrs); + this.setupComponent(attrs); i18n = require('views/i18n'); }); @@ -35,7 +35,7 @@ describeComponent('mail_view/ui/reply_box', function () { it('should use the from field when Reply-To header does not exist', function() { attrs.mail.header.reply_to = undefined; - setupComponent(attrs); + this.setupComponent(attrs); expect(this.component.attr.recipientValues.to).toEqual([attrs.mail.header.from]); }); @@ -43,7 +43,7 @@ describeComponent('mail_view/ui/reply_box', function () { it('should have a subject of Re: <original_message>', function() { attrs.mail.header.subject = 'Very interesting'; - setupComponent(attrs); + this.setupComponent(attrs); expect(this.component.select('subjectDisplay').text()).toEqual(i18n('Re: ')+ attrs.mail.header.subject); }); @@ -52,7 +52,7 @@ describeComponent('mail_view/ui/reply_box', function () { var mailSendEvent = spyOnEvent(document, Pixelated.events.mail.send); attrs.mail.header.message_id = '12345'; - setupComponent(attrs); + this.setupComponent(attrs); $(document).trigger(Pixelated.events.ui.mail.send); @@ -66,7 +66,7 @@ describeComponent('mail_view/ui/reply_box', function () { var mailSendEvent = spyOnEvent(document, Pixelated.events.mail.send); attrs.mail.header.list_id = 'somelist'; - setupComponent(attrs); + this.setupComponent(attrs); $(document).trigger(Pixelated.events.ui.mail.send); expect(mailSendEvent.mostRecentCall.data.header).toEqual(jasmine.objectContaining({ @@ -76,9 +76,9 @@ describeComponent('mail_view/ui/reply_box', function () { it('populates body text area with quote of email being replied', function() { var viewHelper = require('helpers/view_helper'); - spyOn(viewHelper, 'quoteMail').andReturn('quoted email'); + spyOn(viewHelper, 'quoteMail').and.returnValue('quoted email'); - setupComponent(attrs); + this.setupComponent(attrs); expect(viewHelper.quoteMail).toHaveBeenCalledWith(attrs.mail); expect(this.component.select('bodyBox').val()).toBe('quoted email'); diff --git a/web-ui/test/spec/mail_view/ui/reply_section.spec.js b/web-ui/test/spec/mail_view/ui/reply_section.spec.js index c49c0dda..6bd906bc 100644 --- a/web-ui/test/spec/mail_view/ui/reply_section.spec.js +++ b/web-ui/test/spec/mail_view/ui/reply_section.spec.js @@ -5,7 +5,7 @@ describeComponent('mail_view/ui/reply_section', function () { 'use strict'; beforeEach(function () { - setupComponent(); + this.setupComponent(); }); describe('clicking reply buttons', function() { 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 06f3b003..e97165f1 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 @@ -6,7 +6,7 @@ describeComponent('mail_view/ui/send_button', function () { describe('send button', function () { beforeEach(function () { - setupComponent('<button />'); + this.setupComponent('<button />'); }); describe('when it is disabled', function () { |