summaryrefslogtreecommitdiff
path: root/web-ui/test/spec
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/test/spec')
-rw-r--r--web-ui/test/spec/helpers/monitored_ajax_call.spec.js38
-rw-r--r--web-ui/test/spec/search/results_highlighter.spec.js4
-rw-r--r--web-ui/test/spec/services/mail_service.spec.js18
3 files changed, 40 insertions, 20 deletions
diff --git a/web-ui/test/spec/helpers/monitored_ajax_call.spec.js b/web-ui/test/spec/helpers/monitored_ajax_call.spec.js
index bf7a2db4..972ca3ae 100644
--- a/web-ui/test/spec/helpers/monitored_ajax_call.spec.js
+++ b/web-ui/test/spec/helpers/monitored_ajax_call.spec.js
@@ -35,6 +35,44 @@ define(['helpers/monitored_ajax'], function (monitoredAjax) {
expect(component.trigger).toHaveBeenCalledWith(document, Pixelated.events.ui.userAlerts.displayMessage,
{ message: 'Server Message' });
});
+ });
+
+ describe('when user seems to be logged out', function () {
+ var component, browser;
+
+ beforeEach(function () {
+ component = { trigger: function () {}};
+ browser = require('helpers/browser');
+
+ });
+
+ it('will redirect the browser to the location specified', function () {
+ var redirectUrl = '/some/redirect/url';
+ var deferred = $.Deferred();
+ spyOn($, 'ajax').and.returnValue(deferred);
+ var spyRedirect = spyOn(browser, 'redirect').and.returnValue($.Deferred());
+
+ monitoredAjax(component, '/some/url', {});
+
+ deferred.reject({status: 302, getResponseHeader: function (_) {return redirectUrl;}}, '', '');
+
+ expect(spyRedirect).toHaveBeenCalled();
+ expect(spyRedirect.calls.mostRecent().args[0]).toEqual(redirectUrl);
+ });
+
+ it ('will redirect the browser to root if authentication is required', function () {
+ var redirectUrl = '/';
+ var deferred = $.Deferred();
+ spyOn($, 'ajax').and.returnValue(deferred);
+ var spyRedirect = spyOn(browser, 'redirect').and.returnValue($.Deferred());
+
+ monitoredAjax(component, '/some/url', {});
+
+ deferred.reject({status: 401}, '', '');
+
+ expect(spyRedirect).toHaveBeenCalled();
+ expect(spyRedirect.calls.mostRecent().args[0]).toEqual(redirectUrl);
+ });
});
});
diff --git a/web-ui/test/spec/search/results_highlighter.spec.js b/web-ui/test/spec/search/results_highlighter.spec.js
index 523c3599..cfb61e9c 100644
--- a/web-ui/test/spec/search/results_highlighter.spec.js
+++ b/web-ui/test/spec/search/results_highlighter.spec.js
@@ -1,7 +1,7 @@
describeComponent('search/results_highlighter', function () {
'use strict';
- it('highlights only words that matches with the keywords given', function () {
+ it('highlights words or parts of words that match with the keywords given', function () {
this.setupComponent('<div id="text">Any one seeing too many open bugs</div>');
this.component.attr = {keywords: ['any']};
@@ -9,7 +9,7 @@ describeComponent('search/results_highlighter', function () {
var highlightedWords = this.component.$node.find('.search-highlight').length;
- expect(highlightedWords).toEqual(1);
+ expect(highlightedWords).toEqual(2);
});
it('resets highlights when a new search is performed', function() {
diff --git a/web-ui/test/spec/services/mail_service.spec.js b/web-ui/test/spec/services/mail_service.spec.js
index 2cf69a9d..7fb2bfda 100644
--- a/web-ui/test/spec/services/mail_service.spec.js
+++ b/web-ui/test/spec/services/mail_service.spec.js
@@ -130,24 +130,6 @@ describeComponent('services/mail_service', function () {
expect(spyAjax.calls.mostRecent().args[1].type).toEqual('DELETE');
});
- describe('when request fails', function () {
- it ('will redirect the browser to the location specified', function () {
- var browser = require('helpers/browser');
- var redirectUrl = '/some/redirect/url';
- var me = {};
- var deferred = $.Deferred();
- spyOn($, 'ajax').and.returnValue(deferred);
- var spyRedirect = spyOn(browser, 'redirect').and.returnValue($.Deferred());
-
- this.component.trigger(Pixelated.events.mail.want, { caller: me, mail: email1.ident });
-
- deferred.reject({status: 302, getResponseHeader: function (_) {return redirectUrl;}}, '', '');
-
- expect(spyRedirect).toHaveBeenCalled();
- expect(spyRedirect.calls.mostRecent().args[0]).toEqual(redirectUrl);
- });
- });
-
describe('when successfuly deletes an email', function () {
var displayMessageEvent, uncheckAllEvent, mailsDeletedEvent;