aboutsummaryrefslogtreecommitdiffstats
path: root/core/js/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-11-10 09:50:46 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-11-13 08:46:35 +0100
commitae0a496da83613dc8b41540f2fa32479a3ec3f07 (patch)
tree494fdf6e463a0691356b41d154d2cc7b8881168f /core/js/tests
parent25f8d76f266d53fa4b6f0f3c4fa65febc7b31253 (diff)
downloadnextcloud-server-ae0a496da83613dc8b41540f2fa32479a3ec3f07.tar.gz
nextcloud-server-ae0a496da83613dc8b41540f2fa32479a3ec3f07.zip
Bump jquery from 2.2.4 to 3.1.0
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/js/tests')
-rw-r--r--core/js/tests/specs/contactsmenuSpec.js4
-rw-r--r--core/js/tests/specs/jquery.contactsmenuSpec.js62
-rw-r--r--core/js/tests/specs/l10nSpec.js60
-rw-r--r--core/js/tests/specs/oc-backbone-webdavSpec.js88
-rw-r--r--core/js/tests/specs/setupchecksSpec.js3
5 files changed, 135 insertions, 82 deletions
diff --git a/core/js/tests/specs/contactsmenuSpec.js b/core/js/tests/specs/contactsmenuSpec.js
index 3fa8671e2ac..54e3152b27a 100644
--- a/core/js/tests/specs/contactsmenuSpec.js
+++ b/core/js/tests/specs/contactsmenuSpec.js
@@ -243,13 +243,13 @@ describe('Contacts menu', function() {
// Open the first one
$menuEl.find('.contact').eq(0).find('.other-actions').click();
- expect($menuEl.find('.contact').eq(0).find('.menu').css('display')).toBe('block');
+ expect($menuEl.find('.contact').eq(0).find('.menu').css('display')).toBe('');
expect($menuEl.find('.contact').eq(1).find('.menu').css('display')).toBe('none');
// Open the second one
$menuEl.find('.contact').eq(1).find('.other-actions').click();
expect($menuEl.find('.contact').eq(0).find('.menu').css('display')).toBe('none');
- expect($menuEl.find('.contact').eq(1).find('.menu').css('display')).toBe('block');
+ expect($menuEl.find('.contact').eq(1).find('.menu').css('display')).toBe('');
// Close the second one
$menuEl.find('.contact').eq(1).find('.other-actions').click();
diff --git a/core/js/tests/specs/jquery.contactsmenuSpec.js b/core/js/tests/specs/jquery.contactsmenuSpec.js
index 9cad302a998..c6807c850a9 100644
--- a/core/js/tests/specs/jquery.contactsmenuSpec.js
+++ b/core/js/tests/specs/jquery.contactsmenuSpec.js
@@ -22,7 +22,9 @@ describe('jquery.contactsMenu tests', function() {
});
afterEach(function() {
+ $selector1.off();
$selector1.remove();
+ $selector2.off();
$selector2.remove();
$appendTo.remove();
});
@@ -100,10 +102,12 @@ describe('jquery.contactsMenu tests', function() {
});
describe('send requests to the server and render', function() {
- it('load a topaction only', function() {
+ it('load a topaction only', function(done) {
$('#selector1, #selector2').contactsMenu('user', 0, $appendTo);
$selector1.click();
+ expect(fakeServer.requests[0].method).toEqual('POST');
+ expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne');
fakeServer.requests[0].respond(
200,
{ 'Content-Type': 'application/json; charset=utf-8' },
@@ -117,13 +121,15 @@ describe('jquery.contactsMenu tests', function() {
"actions": []
})
);
- expect(fakeServer.requests[0].method).toEqual('POST');
- expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne');
- expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="mailto:bar%40baz.wtf"><img src="foo.svg"><span>bar@baz.wtf</span></a></li></ul></div>');
+ $selector1.on('load', function() {
+ expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="mailto:bar%40baz.wtf"><img src="foo.svg"><span>bar@baz.wtf</span></a></li></ul></div>');
+
+ done();
+ });
});
- it('load topaction and more actions', function() {
+ it('load topaction and more actions', function(done) {
$('#selector1, #selector2').contactsMenu('user', 0, $appendTo);
$selector1.click();
@@ -147,10 +153,14 @@ describe('jquery.contactsMenu tests', function() {
expect(fakeServer.requests[0].method).toEqual('POST');
expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne');
- expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="mailto:bar%40baz.wtf"><img src="foo.svg"><span>bar@baz.wtf</span></a></li><li><a href="http://localhost/index.php/apps/contacts"><img src="details.svg"><span>Details</span></a></li></ul></div>');
+ $selector1.on('load', function() {
+ expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="mailto:bar%40baz.wtf"><img src="foo.svg"><span>bar@baz.wtf</span></a></li><li><a href="http://localhost/index.php/apps/contacts"><img src="details.svg"><span>Details</span></a></li></ul></div>');
+
+ done();
+ });
});
- it('load no actions', function() {
+ it('load no actions', function(done) {
$('#selector1, #selector2').contactsMenu('user', 0, $appendTo);
$selector1.click();
@@ -167,10 +177,14 @@ describe('jquery.contactsMenu tests', function() {
expect(fakeServer.requests[0].method).toEqual('POST');
expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne');
- expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="#"><span>No action available</span></a></li></ul></div>');
+ $selector1.on('load', function() {
+ expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="#"><span>No action available</span></a></li></ul></div>');
+
+ done();
+ });
});
- it('should throw an error', function() {
+ it('should throw an error', function(done) {
$('#selector1, #selector2').contactsMenu('user', 0, $appendTo);
$selector1.click();
@@ -182,10 +196,14 @@ describe('jquery.contactsMenu tests', function() {
expect(fakeServer.requests[0].method).toEqual('POST');
expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne');
- expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="#"><span>Error fetching contact actions</span></a></li></ul></div>');
+ $selector1.on('loaderror', function() {
+ expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="#"><span>Error fetching contact actions</span></a></li></ul></div>');
+
+ done();
+ });
});
- it('should handle 404', function() {
+ it('should handle 404', function(done) {
$('#selector1, #selector2').contactsMenu('user', 0, $appendTo);
$selector1.click();
@@ -197,17 +215,21 @@ describe('jquery.contactsMenu tests', function() {
expect(fakeServer.requests[0].method).toEqual('POST');
expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne');
- expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="#"><span>No action available</span></a></li></ul></div>');
+ $selector1.on('loaderror', function() {
+ expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded" style="display: block;"><ul><li class="hidden"><a><span class="icon-loading-small"></span></a></li><li><a href="#"><span>No action available</span></a></li></ul></div>');
+
+ done();
+ });
});
- });
- it('click anywhere else to close the menu', function() {
- $('#selector1, #selector2').contactsMenu('user', 0, $appendTo);
+ it('click anywhere else to close the menu', function() {
+ $('#selector1, #selector2').contactsMenu('user', 0, $appendTo);
- expect($appendTo.find('div').hasClass('hidden')).toEqual(true);
- $selector1.click();
- expect($appendTo.find('div').hasClass('hidden')).toEqual(false);
- $(document).click();
- expect($appendTo.find('div').hasClass('hidden')).toEqual(true);
+ expect($appendTo.find('div').hasClass('hidden')).toEqual(true);
+ $selector1.click();
+ expect($appendTo.find('div').hasClass('hidden')).toEqual(false);
+ $(document).click();
+ expect($appendTo.find('div').hasClass('hidden')).toEqual(true);
+ });
});
});
diff --git a/core/js/tests/specs/l10nSpec.js b/core/js/tests/specs/l10nSpec.js
index 67a5ab710d5..18c1adabea1 100644
--- a/core/js/tests/specs/l10nSpec.js
+++ b/core/js/tests/specs/l10nSpec.js
@@ -110,18 +110,30 @@ describe('OC.L10N tests', function() {
});
});
describe('async loading of translations', function() {
- it('loads bundle for given app and calls callback', function() {
+ it('loads bundle for given app and calls callback', function(done) {
var localeStub = sinon.stub(OC, 'getLocale').returns('zh_CN');
var callbackStub = sinon.stub();
var promiseStub = sinon.stub();
- OC.L10N.load(TEST_APP, callbackStub).then(promiseStub);
+ var loading = OC.L10N.load(TEST_APP, callbackStub);
expect(callbackStub.notCalled).toEqual(true);
- expect(promiseStub.notCalled).toEqual(true);
- expect(fakeServer.requests.length).toEqual(1);
var req = fakeServer.requests[0];
- expect(req.url).toEqual(
- OC.getRootPath() + '/apps3/' + TEST_APP + '/l10n/zh_CN.json'
- );
+
+ 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('你好世界!');
+ localeStub.restore();
+ })
+ .then(done);
+
+ expect(promiseStub.notCalled).toEqual(true);
req.respond(
200,
{ 'Content-Type': 'application/json' },
@@ -130,32 +142,30 @@ describe('OC.L10N tests', function() {
pluralForm: 'nplurals=2; plural=(n != 1);'
})
);
-
- expect(callbackStub.calledOnce).toEqual(true);
- expect(promiseStub.calledOnce).toEqual(true);
- expect(t(TEST_APP, 'Hello world!')).toEqual('你好世界!');
- localeStub.restore();
});
- it('calls callback if translation already available', function() {
- var promiseStub = sinon.stub();
+ 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(promiseStub);
- expect(callbackStub.calledOnce).toEqual(true);
- expect(promiseStub.calledOnce).toEqual(true);
- expect(fakeServer.requests.length).toEqual(0);
+ 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() {
- var localeStub = sinon.stub(OC, 'getLocale').returns('en');
- var promiseStub = sinon.stub();
+ it('calls callback if locale is en', function(done) {
var callbackStub = sinon.stub();
- OC.L10N.load(TEST_APP, callbackStub).then(promiseStub);
- expect(callbackStub.calledOnce).toEqual(true);
- expect(promiseStub.calledOnce).toEqual(true);
- expect(fakeServer.requests.length).toEqual(0);
+ OC.L10N.load(TEST_APP, callbackStub)
+ .then(function() {
+ expect(callbackStub.calledOnce).toEqual(true);
+ expect(fakeServer.requests.length).toEqual(0);
+ })
+ .then(done)
+ .catch(done);
});
});
});
diff --git a/core/js/tests/specs/oc-backbone-webdavSpec.js b/core/js/tests/specs/oc-backbone-webdavSpec.js
index 97281e982ce..6f48d0c92d2 100644
--- a/core/js/tests/specs/oc-backbone-webdavSpec.js
+++ b/core/js/tests/specs/oc-backbone-webdavSpec.js
@@ -71,7 +71,7 @@ describe('Backbone Webdav extension', function() {
});
});
- it('makes a POST request to create model into collection', function() {
+ it('makes a POST request to create model into collection', function(done) {
var collection = new TestCollection();
var model = collection.create({
firstName: 'Hello',
@@ -104,10 +104,14 @@ describe('Backbone Webdav extension', function() {
}
});
- expect(model.id).toEqual('123');
+ setTimeout(function() {
+ expect(model.id).toEqual('123');
+
+ done();
+ }, 0)
});
- it('uses PROPFIND to retrieve collection', function() {
+ it('uses PROPFIND to retrieve collection', function(done) {
var successStub = sinon.stub();
var errorStub = sinon.stub();
var collection = new TestCollection();
@@ -164,23 +168,27 @@ describe('Backbone Webdav extension', function() {
]
});
- expect(collection.length).toEqual(2);
+ setTimeout(function() {
+ expect(collection.length).toEqual(2);
- var model = collection.get('123');
- expect(model.id).toEqual('123');
- expect(model.get('firstName')).toEqual('Hello');
- expect(model.get('lastName')).toEqual('World');
+ var model = collection.get('123');
+ expect(model.id).toEqual('123');
+ expect(model.get('firstName')).toEqual('Hello');
+ expect(model.get('lastName')).toEqual('World');
+
+ model = collection.get('456');
+ expect(model.id).toEqual('456');
+ expect(model.get('firstName')).toEqual('Test');
+ expect(model.get('lastName')).toEqual('Person');
- model = collection.get('456');
- expect(model.id).toEqual('456');
- expect(model.get('firstName')).toEqual('Test');
- expect(model.get('lastName')).toEqual('Person');
+ expect(successStub.calledOnce).toEqual(true);
+ expect(errorStub.notCalled).toEqual(true);
- expect(successStub.calledOnce).toEqual(true);
- expect(errorStub.notCalled).toEqual(true);
+ done();
+ }, 0)
});
- function testMethodError(doCall) {
+ function testMethodError(doCall, done) {
var successStub = sinon.stub();
var errorStub = sinon.stub();
@@ -191,20 +199,24 @@ describe('Backbone Webdav extension', function() {
body: ''
});
- expect(successStub.notCalled).toEqual(true);
- expect(errorStub.calledOnce).toEqual(true);
+ setTimeout(function() {
+ expect(successStub.notCalled).toEqual(true);
+ expect(errorStub.calledOnce).toEqual(true);
+
+ done();
+ }, 0)
}
- it('calls error handler if error status in PROPFIND response', function() {
+ it('calls error handler if error status in PROPFIND response', function(done) {
testMethodError(function(success, error) {
var collection = new TestCollection();
collection.fetch({
success: success,
error: error
});
- });
+ }, done);
});
- it('calls error handler if error status in POST response', function() {
+ it('calls error handler if error status in POST response', function(done) {
testMethodError(function(success, error) {
var collection = new TestCollection();
collection.create({
@@ -214,7 +226,7 @@ describe('Backbone Webdav extension', function() {
success: success,
error: error
});
- });
+ }, done);
});
});
describe('models', function() {
@@ -281,7 +293,7 @@ describe('Backbone Webdav extension', function() {
expect(model.get('married')).toEqual(true);
});
- it('uses PROPFIND to fetch single model', function() {
+ it('uses PROPFIND to fetch single model', function(done) {
var model = new TestModel({
id: '123'
});
@@ -319,11 +331,15 @@ describe('Backbone Webdav extension', function() {
}
});
- expect(model.id).toEqual('123');
- expect(model.get('firstName')).toEqual('Hello');
- expect(model.get('lastName')).toEqual('World');
- expect(model.get('age')).toEqual(35);
- expect(model.get('married')).toEqual(true);
+ setTimeout(function() {
+ expect(model.id).toEqual('123');
+ expect(model.get('firstName')).toEqual('Hello');
+ expect(model.get('lastName')).toEqual('World');
+ expect(model.get('age')).toEqual(35);
+ expect(model.get('married')).toEqual(true);
+
+ done();
+ });
});
it('makes a DELETE request to destroy model', function() {
var model = new TestModel({
@@ -350,7 +366,7 @@ describe('Backbone Webdav extension', function() {
});
});
- function testMethodError(doCall) {
+ function testMethodError(doCall, done) {
var successStub = sinon.stub();
var errorStub = sinon.stub();
@@ -361,20 +377,24 @@ describe('Backbone Webdav extension', function() {
body: ''
});
- expect(successStub.notCalled).toEqual(true);
- expect(errorStub.calledOnce).toEqual(true);
+ setTimeout(function() {
+ expect(successStub.notCalled).toEqual(true);
+ expect(errorStub.calledOnce).toEqual(true);
+
+ done();
+ });
}
- it('calls error handler if error status in PROPFIND response', function() {
+ it('calls error handler if error status in PROPFIND response', function(done) {
testMethodError(function(success, error) {
var model = new TestModel();
model.fetch({
success: success,
error: error
});
- });
+ }, done);
});
- it('calls error handler if error status in PROPPATCH response', function() {
+ it('calls error handler if error status in PROPPATCH response', function(done) {
testMethodError(function(success, error) {
var model = new TestModel();
model.save({
@@ -383,7 +403,7 @@ describe('Backbone Webdav extension', function() {
success: success,
error: error
});
- });
+ }, done);
});
});
});
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index 3b54a3ff66a..a0a3c2a4ba9 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -1114,7 +1114,8 @@ describe('OC.SetupChecks tests', function() {
{
'Content-Type': 'application/json',
'Strict-Transport-Security': 'max-age=15768000'
- }
+ },
+ '{}'
);
async.done(function( data, s, x ){