From 27544144cec06324a5fe4494034e893b7c5a66ff Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 22 Feb 2016 17:19:08 +0100 Subject: [PATCH] Fix unit tests affected by side effects The notification tests were not restoring the clock properly, but indirectly helped other tests pass. Since now we're restoring the clock properly, the other tests were fixed to still work. --- apps/files/tests/js/fileactionsSpec.js | 4 +++- apps/systemtags/tests/js/systemtagsinfoviewSpec.js | 3 +++ core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js index a905a4d969d..4f4d4d3d197 100644 --- a/apps/files/tests/js/fileactionsSpec.js +++ b/apps/files/tests/js/fileactionsSpec.js @@ -20,9 +20,10 @@ */ describe('OCA.Files.FileActions tests', function() { - var fileList, fileActions; + var fileList, fileActions, clock; beforeEach(function() { + clock = sinon.useFakeTimers(); // init horrible parameters var $body = $('#testArea'); $body.append(''); @@ -63,6 +64,7 @@ describe('OCA.Files.FileActions tests', function() { fileActions = null; fileList.destroy(); fileList = undefined; + clock.restore(); $('#dir, #permissions, #filestable').remove(); }); it('calling clear() clears file actions', function() { diff --git a/apps/systemtags/tests/js/systemtagsinfoviewSpec.js b/apps/systemtags/tests/js/systemtagsinfoviewSpec.js index 0fb4e7b22c2..27724822c2e 100644 --- a/apps/systemtags/tests/js/systemtagsinfoviewSpec.js +++ b/apps/systemtags/tests/js/systemtagsinfoviewSpec.js @@ -22,14 +22,17 @@ describe('OCA.SystemTags.SystemTagsInfoView tests', function() { var isAdminStub; var view; + var clock; beforeEach(function() { + clock = sinon.useFakeTimers(); view = new OCA.SystemTags.SystemTagsInfoView(); $('#testArea').append(view.$el); isAdminStub = sinon.stub(OC, 'isUserAdmin').returns(true); }); afterEach(function() { isAdminStub.restore(); + clock.restore(); view.remove(); view = undefined; }); diff --git a/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js b/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js index d62ef672f4d..aadf0de53f2 100644 --- a/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js +++ b/core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js @@ -20,9 +20,10 @@ */ describe('OC.SystemTags.SystemTagsInputField tests', function() { - var view, select2Stub; + var view, select2Stub, clock; beforeEach(function() { + clock = sinon.useFakeTimers(); var $container = $('
'); select2Stub = sinon.stub($.fn, 'select2'); select2Stub.returnsThis(); @@ -31,6 +32,7 @@ describe('OC.SystemTags.SystemTagsInputField tests', function() { afterEach(function() { select2Stub.restore(); OC.SystemTags.collection.reset(); + clock.restore(); view.remove(); view = undefined; }); -- 2.39.5