summaryrefslogtreecommitdiffstats
path: root/core/js/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-04-22 11:23:39 +0200
committerLukas Reschke <lukas@owncloud.com>2016-04-22 11:23:39 +0200
commit2c4ef370254fbe4bf9e6d7bbd67e5be2d3238d14 (patch)
tree6fbe8795f06bba590b0858149d099430a97cabb3 /core/js/tests
parent3b3cff4f79da1b9db692739c71663b39f099a17d (diff)
parent62024d74d407514beb7773879cba895b457e87cb (diff)
downloadnextcloud-server-2c4ef370254fbe4bf9e6d7bbd67e5be2d3238d14.tar.gz
nextcloud-server-2c4ef370254fbe4bf9e6d7bbd67e5be2d3238d14.zip
Merge pull request #24126 from owncloud/err-reload-delay
Delay reloading the page if an ajax error occurs, show notification
Diffstat (limited to 'core/js/tests')
-rw-r--r--core/js/tests/specs/coreSpec.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index 02eb1b95c1d..3d19a38c416 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -938,10 +938,13 @@ describe('Core base tests', function() {
});
describe('global ajax errors', function() {
var reloadStub, ajaxErrorStub, clock;
+ var notificationStub;
+ var waitTimeMs = 6000;
beforeEach(function() {
clock = sinon.useFakeTimers();
reloadStub = sinon.stub(OC, 'reload');
+ notificationStub = sinon.stub(OC.Notification, 'show');
// unstub the error processing method
ajaxErrorStub = OC._processAjaxError;
ajaxErrorStub.restore();
@@ -949,6 +952,7 @@ describe('Core base tests', function() {
});
afterEach(function() {
reloadStub.restore();
+ notificationStub.restore();
clock.restore();
});
@@ -973,7 +977,7 @@ describe('Core base tests', function() {
$(document).trigger(new $.Event('ajaxError'), xhr);
// trigger timers
- clock.tick(1000);
+ clock.tick(waitTimeMs);
if (expectedCall) {
expect(reloadStub.calledOnce).toEqual(true);
@@ -989,7 +993,7 @@ describe('Core base tests', function() {
$(document).trigger(new $.Event('ajaxError'), xhr);
// trigger timers
- clock.tick(1000);
+ clock.tick(waitTimeMs);
expect(reloadStub.calledOnce).toEqual(true);
});
@@ -1000,9 +1004,17 @@ describe('Core base tests', function() {
$(document).trigger(new $.Event('ajaxError'), xhr);
- clock.tick(1000);
+ clock.tick(waitTimeMs);
expect(reloadStub.notCalled).toEqual(true);
});
+ it('displays notification', function() {
+ var xhr = { status: 401 };
+
+ $(document).trigger(new $.Event('ajaxError'), xhr);
+
+ clock.tick(waitTimeMs);
+ expect(notificationStub.calledOnce).toEqual(true);
+ });
});
});