]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix core tests by stubbing debounce 32733/head
authorVincent Petry <vincent@nextcloud.com>
Tue, 26 Jul 2022 13:44:57 +0000 (15:44 +0200)
committerVincent Petry <vincent@nextcloud.com>
Tue, 26 Jul 2022 13:46:17 +0000 (15:46 +0200)
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
core/js/tests/specs/coreSpec.js

index 8adea2123e09aa9b68d9bff6aed5dfe2ff555cbc..7f5a8b10d898db451256437b19f2721d55f2fd8f 100644 (file)
 */
 
 describe('Core base tests', function() {
+       var debounceStub
+       beforeEach(function() {
+               debounceStub = sinon.stub(_, 'debounce').callsFake(function(callback) {
+                       return function() {
+                               // defer instead of debounce, to make it work with clock
+                               _.defer(callback);
+                       };
+               });
+       });
        afterEach(function() {
                // many tests call window.initCore so need to unregister global events
                // ideally in the future we'll need a window.unloadCore() function
@@ -28,6 +37,7 @@ describe('Core base tests', function() {
                $(document).off('beforeunload.main');
                OC._userIsNavigatingAway = false;
                OC._reloadCalled = false;
+               debounceStub.restore();
        });
        describe('Base values', function() {
                it('Sets webroots', function() {