summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/search
diff options
context:
space:
mode:
authorOla Bini <ola.bini@gmail.com>2014-07-31 19:29:33 -0300
committerOla Bini <ola.bini@gmail.com>2014-07-31 19:29:33 -0300
commit04cf441c5ae18400c6b4865b0b37a71718dc9d46 (patch)
treedd0b0d049ec00389e2d4561b226c46eb1682b997 /web-ui/test/spec/search
parent639a663a4c37020003586438fdcd7ac529a00f10 (diff)
Add web-ui based on previous code
Diffstat (limited to 'web-ui/test/spec/search')
-rw-r--r--web-ui/test/spec/search/search_trigger.spec.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/web-ui/test/spec/search/search_trigger.spec.js b/web-ui/test/spec/search/search_trigger.spec.js
new file mode 100644
index 00000000..aaeba3b1
--- /dev/null
+++ b/web-ui/test/spec/search/search_trigger.spec.js
@@ -0,0 +1,78 @@
+/*global jasmine */
+/*global Smail */
+
+describeComponent('search/search_trigger', function () {
+ 'use strict';
+ var self;
+
+ beforeEach(function () {
+ setupComponent();
+ self = this;
+ });
+
+ function submitSearch(queryString) {
+ self.component.select('input').val(queryString);
+ self.component.select('form').submit();
+ }
+
+ it('should trigger search when the submit occurs', function () {
+ var spy = spyOnEvent(document, Smail.events.search.perform);
+
+ submitSearch('tanana');
+ expect(spy).toHaveBeenTriggeredOnAndWith(document, { query: 'tanana' });
+ });
+
+ it('should select the "all" tag when submit occurs but should skip mail list refresh', function (){
+ var tagSelectEvent = spyOnEvent(document, Smail.events.ui.tag.select);
+
+ submitSearch('tanana');
+
+ expect(tagSelectEvent).toHaveBeenTriggeredOnAndWith(document, {
+ tag: 'all',
+ skipMailListRefresh: true
+ });
+ });
+
+ it('should select the "all" tag when an empty submit occurs and shoud refresh mail list', function() {
+ var tagSelectEvent = spyOnEvent(document, Smail.events.ui.tag.select);
+ var emptySearchEvent = spyOnEvent(document, Smail.events.search.empty);
+
+ submitSearch('');
+
+ expect(emptySearchEvent).toHaveBeenTriggeredOn(document);
+ expect(tagSelectEvent).toHaveBeenTriggeredOnAndWith(document, { tag: 'all'});
+
+ });
+
+ it('should clear input when selecting a new tag', function(){
+ submitSearch('tanana');
+ $(document).trigger(Smail.events.ui.tag.selected, { tag: 'inbox'});
+ expect(self.component.select('input').val()).toBe('');
+ });
+
+ it('should add place holder on input value after doing a search', function(){
+ submitSearch('teste');
+ expect(self.component.select('input').val()).toBe('Search results for: teste');
+ });
+
+ it('should remove place holder on input value when input is on focus', function(){
+ submitSearch('teste');
+ this.component.select('input').focus();
+ expect(self.component.select('input').val()).toBe('teste');
+ });
+
+ it('should remove place holder on input value when input is not on focus', function(){
+ submitSearch('teste');
+ this.component.select('input').focus();
+ this.component.select('input').blur();
+ expect(self.component.select('input').val()).toBe('Search results for: teste');
+ });
+
+ it('should not change input value when input is empty', function(){
+ submitSearch('');
+ this.component.select('input').focus();
+ expect(self.component.select('input').val()).toBe('');
+ });
+
+
+});