aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin McCorkell <robin@mccorkell.me.uk>2016-04-20 22:09:59 +0100
committerVincent Petry <pvince81@owncloud.com>2016-06-08 17:33:00 +0200
commit3f16ce740348e87fa015a825164a49151be554d9 (patch)
tree6de1c2c5fc40192a5927bd0279c3e44e6384fef2
parent40f066ab6d578a4ad28452596b0d0d82bfcbef88 (diff)
downloadnextcloud-server-3f16ce740348e87fa015a825164a49151be554d9.tar.gz
nextcloud-server-3f16ce740348e87fa015a825164a49151be554d9.zip
Add test for reload delay
-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 f18ecbc1a44..0296a3675a3 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -935,10 +935,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();
@@ -946,6 +949,7 @@ describe('Core base tests', function() {
});
afterEach(function() {
reloadStub.restore();
+ notificationStub.restore();
clock.restore();
});
@@ -970,7 +974,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);
@@ -986,7 +990,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);
});
@@ -997,9 +1001,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);
+ });
});
});