diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-01-10 15:08:03 +0100 |
---|---|---|
committer | Vincent Petry <vincent@nextcloud.com> | 2022-01-10 15:08:03 +0100 |
commit | 6aba3964d32e8e5589590a60b3d88ce36fd6f4a7 (patch) | |
tree | ae7d63c60c4e2da8be1db6e542daac6f7e433ddb /core | |
parent | 82ded36358c3e77e786d88709ff0d8a00c68930a (diff) | |
download | nextcloud-server-6aba3964d32e8e5589590a60b3d88ce36fd6f4a7.tar.gz nextcloud-server-6aba3964d32e8e5589590a60b3d88ce36fd6f4a7.zip |
Fix JS tests after test lib updates
Prevent XHR during load by checking window.TESTING.
Adjust some expected values.
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/js/tests/specs/contactsmenuSpec.js | 2 | ||||
-rw-r--r-- | core/js/tests/specs/jquery.contactsmenuSpec.js | 15 |
2 files changed, 11 insertions, 6 deletions
diff --git a/core/js/tests/specs/contactsmenuSpec.js b/core/js/tests/specs/contactsmenuSpec.js index 54e3152b27a..7eaf2660799 100644 --- a/core/js/tests/specs/contactsmenuSpec.js +++ b/core/js/tests/specs/contactsmenuSpec.js @@ -73,7 +73,7 @@ describe('Contacts menu', function() { opening.then(function() { expect($menuEl.html()).toContain('Could not load your contacts'); - expect(console.error).toHaveBeenCalledTimes(1); + expect(console.error).toHaveBeenCalled(); done(); }, function(e) { done.fail(e); diff --git a/core/js/tests/specs/jquery.contactsmenuSpec.js b/core/js/tests/specs/jquery.contactsmenuSpec.js index c6807c850a9..d0bd9c8dde4 100644 --- a/core/js/tests/specs/jquery.contactsmenuSpec.js +++ b/core/js/tests/specs/jquery.contactsmenuSpec.js @@ -123,7 +123,8 @@ describe('jquery.contactsMenu tests', function() { ); $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>'); + // FIXME: don't compare HTML one to one but check specific text in the output + expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded"><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(); }); @@ -154,7 +155,8 @@ describe('jquery.contactsMenu tests', function() { expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne'); $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>'); + // FIXME: don't compare HTML one to one but check specific text in the output + expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded"><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(); }); @@ -178,7 +180,8 @@ describe('jquery.contactsMenu tests', function() { expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne'); $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>'); + // FIXME: don't compare HTML one to one but check specific text in the output + expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded"><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(); }); @@ -197,7 +200,8 @@ describe('jquery.contactsMenu tests', function() { expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne'); $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>'); + // FIXME: don't compare HTML one to one but check specific text in the output + expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded"><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(); }); @@ -216,7 +220,8 @@ describe('jquery.contactsMenu tests', function() { expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne'); $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>'); + // FIXME: don't compare HTML one to one but check specific text in the output + expect($appendTo.html().replace(/[\r\n\t]?(\ \ +)?/g, '')).toEqual('<div class="menu popovermenu menu-left contactsmenu-popover loaded"><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(); }); |