diff options
Diffstat (limited to 'web-ui/test/spec')
3 files changed, 53 insertions, 5 deletions
diff --git a/web-ui/test/spec/dispatchers/middle_pane_dispatchers.spec.js b/web-ui/test/spec/dispatchers/middle_pane_dispatchers.spec.js index 3d55cbaa..220ad96d 100644 --- a/web-ui/test/spec/dispatchers/middle_pane_dispatchers.spec.js +++ b/web-ui/test/spec/dispatchers/middle_pane_dispatchers.spec.js @@ -24,10 +24,10 @@ describeComponent('dispatchers/middle_pane_dispatcher', function () { }); describe('no emails available', function () { - var noMailsAvailablePane; + var noMailsAvailablePane, attachToSpy; beforeEach(function () { noMailsAvailablePane = require('mail_view/ui/no_mails_available_pane'); - spyOn(noMailsAvailablePane, 'attachTo'); + attachToSpy = spyOn(noMailsAvailablePane, 'attachTo'); spyOn(noMailsAvailablePane, 'teardownAll'); }); @@ -47,5 +47,11 @@ describeComponent('dispatchers/middle_pane_dispatcher', function () { expect(noMailsAvailablePane.teardownAll).toHaveBeenCalled(); }); + it('should give search information to component', function () { + var mail_list = { mails: [], tag: 'all', forSearch: 'search'}; + this.component.trigger(document, Pixelated.events.mails.available, mail_list); + + expect(attachToSpy.calls.mostRecent().args[1]).toEqual({tag: 'all', forSearch: 'search'}); + }); }); }); diff --git a/web-ui/test/spec/mail_view/ui/no_mails_available_pane.spec.js b/web-ui/test/spec/mail_view/ui/no_mails_available_pane.spec.js index 2fee45ac..868efc76 100644 --- a/web-ui/test/spec/mail_view/ui/no_mails_available_pane.spec.js +++ b/web-ui/test/spec/mail_view/ui/no_mails_available_pane.spec.js @@ -6,5 +6,10 @@ describeComponent('mail_view/ui/no_mails_available_pane', function () { this.setupComponent({tag: 'inbox'}); expect(this.$node.html()).toMatch('<div class="text">NO EMAILS IN \'INBOX\'.</div>'); }); + + it('show different message for search with no results', function () { + this.setupComponent({tag: 'all', forSearch: 'search'}); + expect(this.$node.html()).toMatch('<div class="text">NO RESULTS FOR: \'SEARCH\'.</div>'); + }); }); }); diff --git a/web-ui/test/spec/services/mail_service.spec.js b/web-ui/test/spec/services/mail_service.spec.js index 7fb2bfda..d0911768 100644 --- a/web-ui/test/spec/services/mail_service.spec.js +++ b/web-ui/test/spec/services/mail_service.spec.js @@ -93,7 +93,6 @@ describeComponent('services/mail_service', function () { var spyAjax = spyOn($, 'ajax').and.returnValue(deferred); var spyEvent = spyOnEvent(document, Pixelated.events.mail.tags.updated); - var component = jasmine.createSpyObj('component',['successUpdateTags']); this.component.trigger(Pixelated.events.mail.tags.update, { ident: email1.ident, tags: email1.tags }); @@ -111,7 +110,6 @@ describeComponent('services/mail_service', function () { var spyAjax = spyOn($, 'ajax').and.returnValue(deferred); var spyEvent = spyOnEvent(document, Pixelated.events.ui.userAlerts.displayMessage); - var component = jasmine.createSpyObj('component',['failureUpdateTags']); this.component.trigger(Pixelated.events.mail.tags.update, { ident: email1.ident, tags: email1.tags }); @@ -169,7 +167,7 @@ describeComponent('services/mail_service', function () { this.component.trigger(Pixelated.events.mail.delete, {mail: {ident: '43'}}); - deferred.reject({responseJSON: {}}); + deferred.reject({mailsJSON: {}}); expect(spyEvent).toHaveBeenTriggeredOnAndWith(document, {message: i18n('Could not delete email')} ); }); @@ -183,6 +181,45 @@ describeComponent('services/mail_service', function () { expect(spyAjax.calls.all()[0].args[1].data).toEqual(JSON.stringify({ idents: ['43', '44'] } )); }); + // TODO: WIP + describe('when try archive emails', function() { + var deferred, spyAjax, mails; + + beforeEach(function() { + deferred = $.Deferred(); + spyAjax = spyOn($, 'ajax').and.returnValue(deferred); + mails = {checkedMails: [{ident: '43'}, {ident: '44'}]}; + }); + + it('should call triggerArchived', function() { + spyOn(this.component, 'triggerArchived'); + + this.component.trigger(Pixelated.events.mail.archiveMany, mails); + + deferred.resolve(); + expect(this.component.triggerArchived).toHaveBeenCalledWith(mails); + }); + + it('should show an error message when request returns no success', function() { + spyOn(this.component, 'errorMessage'); + + this.component.trigger(Pixelated.events.mail.archiveMany, mails); + + deferred.reject({}); + expect(this.component.errorMessage).toHaveBeenCalledWith(i18n('Could not archive emails')); + }); + + it('make an ajax request to /mails/archive', function() { + this.component.trigger(Pixelated.events.mail.archiveMany, + {checkedMails: [{ident: '43'}, {ident: '44'}]}); + + expect(spyAjax).toHaveBeenCalled(); + expect(spyAjax.calls.mostRecent().args[0]).toEqual('/mails/archive'); + expect(spyAjax.calls.mostRecent().args[1].type).toEqual('POST'); + expect(spyAjax.calls.all()[0].args[1].data).toEqual(JSON.stringify({ idents: ['43', '44'] } )); + }); + }); + describe('when successfuly recovers emails', function () { var displayMessageEvent, uncheckAllEvent, mailsRecoveredEvent; |