aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/tests/specs
diff options
context:
space:
mode:
Diffstat (limited to 'core/js/tests/specs')
-rw-r--r--core/js/tests/specs/coreSpec.js140
-rw-r--r--core/js/tests/specs/l10nSpec.js63
2 files changed, 2 insertions, 201 deletions
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index a7f55d1cf39..3cbd7623a47 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -119,93 +119,6 @@ describe('Core base tests', function() {
})).toEqual('number=123');
});
});
- describe('Session heartbeat', function() {
- var clock,
- oldConfig,
- counter;
-
- beforeEach(function() {
- clock = sinon.useFakeTimers();
- oldConfig = OC.config;
- counter = 0;
-
- fakeServer.autoRespond = true;
- fakeServer.autoRespondAfter = 0;
- fakeServer.respondWith(/\/csrftoken/, function(xhr) {
- counter++;
- xhr.respond(200, {'Content-Type': 'application/json'}, '{"token": "pgBEsb3MzTb1ZPd2mfDZbQ6/0j3OrXHMEZrghHcOkg8=:3khw5PSa+wKQVo4f26exFD3nplud9ECjJ8/Y5zk5/k4="}');
- });
- $(document).off('ajaxComplete'); // ignore previously registered heartbeats
- });
- afterEach(function() {
- clock.restore();
- /* jshint camelcase: false */
- OC.config = oldConfig;
- $(document).off('ajaxError');
- $(document).off('ajaxComplete');
- });
- it('sends heartbeat half the session lifetime when heartbeat enabled', function() {
- /* jshint camelcase: false */
- OC.config = {
- session_keepalive: true,
- session_lifetime: 300
- };
- window.initCore();
-
- expect(counter).toEqual(0);
-
- // less than half, still nothing
- clock.tick(100 * 1000);
- expect(counter).toEqual(0);
-
- // reach past half (160), one call
- clock.tick(55 * 1000);
- expect(counter).toEqual(1);
-
- // almost there to the next, still one
- clock.tick(140 * 1000);
- expect(counter).toEqual(1);
-
- // past it, second call
- clock.tick(20 * 1000);
- expect(counter).toEqual(2);
- });
- it('does not send heartbeat when heartbeat disabled', function() {
- /* jshint camelcase: false */
- OC.config = {
- session_keepalive: false,
- session_lifetime: 300
- };
- window.initCore();
-
- expect(counter).toEqual(0);
-
- clock.tick(1000000);
-
- // still nothing
- expect(counter).toEqual(0);
- });
- it('limits the heartbeat between one minute and one day', function() {
- /* jshint camelcase: false */
- var setIntervalStub = sinon.stub(window, 'setInterval');
- OC.config = {
- session_keepalive: true,
- session_lifetime: 5
- };
- window.initCore();
- expect(setIntervalStub.getCall(0).args[1]).toEqual(60 * 1000);
- setIntervalStub.reset();
-
- OC.config = {
- session_keepalive: true,
- session_lifetime: 48 * 3600
- };
- window.initCore();
- expect(setIntervalStub.getCall(0).args[1]).toEqual(24 * 3600 * 1000);
-
- setIntervalStub.restore();
- });
- });
describe('Parse query string', function() {
it('Parses query string from full URL', function() {
var query = OC.parseQueryString('http://localhost/stuff.php?q=a&b=x');
@@ -359,7 +272,7 @@ describe('Core base tests', function() {
// to make sure they run.
var cit = window.isPhantom?xit:it;
- // must provide the same results as \OC_Util::naturalSortCompare
+ // must provide the same results as \OCP\Util::naturalSortCompare
it('sorts alphabetically', function() {
var a = [
'def',
@@ -765,6 +678,7 @@ describe('Core base tests', function() {
OC.currentUser = 'dummy';
clock = sinon.useFakeTimers();
reloadStub = sinon.stub(OC, 'reload');
+ document.head.dataset.user = 'dummy'
notificationStub = sinon.stub(OC.Notification, 'show');
// unstub the error processing method
ajaxErrorStub = OC._processAjaxError;
@@ -778,47 +692,6 @@ describe('Core base tests', function() {
clock.restore();
});
- it('reloads current page in case of auth error', function() {
- var dataProvider = [
- [200, false],
- [400, false],
- [0, false],
- [401, true],
- [302, true],
- [303, true],
- [307, true]
- ];
-
- for (var i = 0; i < dataProvider.length; i++) {
- var xhr = { status: dataProvider[i][0] };
- var expectedCall = dataProvider[i][1];
-
- reloadStub.reset();
- OC._reloadCalled = false;
-
- $(document).trigger(new $.Event('ajaxError'), xhr);
-
- // trigger timers
- clock.tick(waitTimeMs);
-
- if (expectedCall) {
- expect(reloadStub.calledOnce).toEqual(true);
- } else {
- expect(reloadStub.notCalled).toEqual(true);
- }
- }
- });
- it('reload only called once in case of auth error', function() {
- var xhr = { status: 401 };
-
- $(document).trigger(new $.Event('ajaxError'), xhr);
- $(document).trigger(new $.Event('ajaxError'), xhr);
-
- // trigger timers
- clock.tick(waitTimeMs);
-
- expect(reloadStub.calledOnce).toEqual(true);
- });
it('does not reload the page if the user was navigating away', function() {
var xhr = { status: 0 };
OC._userIsNavigatingAway = true;
@@ -829,16 +702,7 @@ describe('Core base tests', function() {
clock.tick(waitTimeMs);
expect(reloadStub.notCalled).toEqual(true);
});
- it('displays notification', function() {
- var xhr = { status: 401 };
-
- notificationUpdateStub = sinon.stub(OC.Notification, 'showUpdate');
-
- $(document).trigger(new $.Event('ajaxError'), xhr);
- clock.tick(waitTimeMs);
- expect(notificationUpdateStub.notCalled).toEqual(false);
- });
it('shows a temporary notification if the connection is lost', function() {
var xhr = { status: 0 };
spyOn(OC, '_ajaxConnectionLostHandler');
diff --git a/core/js/tests/specs/l10nSpec.js b/core/js/tests/specs/l10nSpec.js
index 03f7fd50796..bd93a13fe74 100644
--- a/core/js/tests/specs/l10nSpec.js
+++ b/core/js/tests/specs/l10nSpec.js
@@ -110,67 +110,4 @@ describe('OC.L10N tests', function() {
checkPlurals();
});
});
- describe('async loading of translations', function() {
- afterEach(() => {
- document.documentElement.removeAttribute('data-locale')
- })
- it('loads bundle for given app and calls callback', function(done) {
- document.documentElement.setAttribute('data-locale', 'zh_CN')
- var callbackStub = sinon.stub();
- var promiseStub = sinon.stub();
- var loading = OC.L10N.load(TEST_APP, callbackStub);
- expect(callbackStub.notCalled).toEqual(true);
- var req = fakeServer.requests[0];
-
- console.warn('fff-', window.OC.appswebroots)
- loading
- .then(promiseStub)
- .then(function() {
- expect(fakeServer.requests.length).toEqual(1);
- expect(req.url).toEqual(
- OC.getRootPath() + '/apps3/' + TEST_APP + '/l10n/zh_CN.json'
- );
-
- expect(callbackStub.calledOnce).toEqual(true);
- expect(promiseStub.calledOnce).toEqual(true);
- expect(t(TEST_APP, 'Hello world!')).toEqual('你好世界!');
- })
- .then(done)
- .catch(e => expect(e).toBe('No error expected!'));
-
- expect(promiseStub.notCalled).toEqual(true);
- req.respond(
- 200,
- { 'Content-Type': 'application/json' },
- JSON.stringify({
- translations: {'Hello world!': '你好世界!'},
- pluralForm: 'nplurals=2; plural=(n != 1);'
- })
- );
- });
- it('calls callback if translation already available', function(done) {
- var callbackStub = sinon.stub();
- spyOn(console, 'warn');
- OC.L10N.register(TEST_APP, {
- 'Hello world!': 'Hallo Welt!'
- });
- OC.L10N.load(TEST_APP, callbackStub)
- .then(function() {
- expect(callbackStub.calledOnce).toEqual(true);
- expect(fakeServer.requests.length).toEqual(0);
- })
- .then(done);
-
- });
- it('calls callback if locale is en', function(done) {
- var callbackStub = sinon.stub();
- OC.L10N.load(TEST_APP, callbackStub)
- .then(function() {
- expect(callbackStub.calledOnce).toEqual(true);
- expect(fakeServer.requests.length).toEqual(0);
- })
- .then(done)
- .catch(done);
- });
- });
});