diff options
Diffstat (limited to 'web-ui')
-rw-r--r-- | web-ui/app/js/mail_view/ui/mail_view.js | 4 | ||||
-rw-r--r-- | web-ui/test/spec/mail_view/ui/mail_view.spec.js | 20 |
2 files changed, 20 insertions, 4 deletions
diff --git a/web-ui/app/js/mail_view/ui/mail_view.js b/web-ui/app/js/mail_view/ui/mail_view.js index 66b33748..eb55dbd5 100644 --- a/web-ui/app/js/mail_view/ui/mail_view.js +++ b/web-ui/app/js/mail_view/ui/mail_view.js @@ -157,7 +157,9 @@ define( if (event.which === ENTER_KEY){ event.preventDefault(); - this.createNewTag(); + if (this.select('newTagInput').val() !== '') { + this.createNewTag(); + } } else if (event.which === ESC_KEY) { event.preventDefault(); this.addTagLoseFocus(); 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 de6fc29d..7d464bcd 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 @@ -166,22 +166,36 @@ describeComponent('mail_view/ui/mail_view', function () { it('creates new tag when pressing Enter key on new tag input', function(){ var tagsUpdateEvent = spyOnEvent(document, Pixelated.events.mail.tags.update); - var tagListRefreshEvent = spyOnEvent(document, Pixelated.events.dispatchers.tags.refreshTagList); - var e = creatingEvent('keydown', 13); this.component.displayMail({}, testData); this.component.select('newTagButton').click(); var newTagInputComponent = this.component.select('newTagInput'); newTagInputComponent.val('Test'); + + var e = creatingEvent('keydown', 13); //ENTER KEY EVENT newTagInputComponent.trigger(e); var tags = testData.mail.tags.slice(); tags.push('Test'); - expect(tagsUpdateEvent).toHaveBeenTriggeredOnAndWith(document, { ident: testData.mail.ident, tags: tags}); }); + it('creates new tag when pressing Enter key on new tag input', function(){ + var tagsUpdateEvent = spyOnEvent(document, Pixelated.events.mail.tags.update); + + this.component.displayMail({}, testData); + this.component.select('newTagButton').click(); + + var newTagInputComponent = this.component.select('newTagInput'); + newTagInputComponent.val(''); + + var e = creatingEvent('keydown', 13); //ENTER KEY EVENT + newTagInputComponent.trigger(e); + + expect(tagsUpdateEvent).not.toHaveBeenTriggeredOnAndWith(document); + }); + it('trigger mail delete event when moving email to trash', function(){ var mailDeleteEvent = spyOnEvent(document, Pixelated.events.ui.mail.delete); |