summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
authorVicente Luchi <vicente.luchi@gmail.com>2015-01-24 17:01:40 -0200
committerDuda Dornelles <ddornell@thoughtworks.com>2015-01-24 17:01:40 -0200
commit2fb15ab3f6ed53434803791df9a38879e44b1195 (patch)
tree4ee91b0e560d5721a5ac725befd5a235e3dabc5a /web-ui
parentcc2886f1346105a54f2b1182fa1f5d38214f9d0e (diff)
#184 - not creating empty tags anymore
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/app/js/mail_view/ui/mail_view.js4
-rw-r--r--web-ui/test/spec/mail_view/ui/mail_view.spec.js20
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);