]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix unit tests affected by side effects
authorVincent Petry <pvince81@owncloud.com>
Mon, 22 Feb 2016 16:19:08 +0000 (17:19 +0100)
committerVincent Petry <pvince81@owncloud.com>
Mon, 22 Feb 2016 16:25:32 +0000 (17:25 +0100)
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
apps/systemtags/tests/js/systemtagsinfoviewSpec.js
core/js/tests/specs/systemtags/systemtagsinputfieldSpec.js

index a905a4d969d8cb6b8b5e037771628253598bcf45..4f4d4d3d197de83c8c921ba2d61122ed239a5c12 100644 (file)
 */
 
 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('<input type="hidden" id="dir" value="/subdir"></input>');
@@ -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() {
index 0fb4e7b22c2288f8d277a5ac256249b150f7cba9..27724822c2e0f4b676c33f675960f523b2004060 100644 (file)
 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;
        });
index d62ef672f4d9a607a39a87b9861d1cc821d9a18d..aadf0de53f2aed0be2e3b94cb16e4bd5606bd7d7 100644 (file)
 */
 
 describe('OC.SystemTags.SystemTagsInputField tests', function() {
-       var view, select2Stub;
+       var view, select2Stub, clock;
 
        beforeEach(function() {
+               clock = sinon.useFakeTimers();
                var $container = $('<div class="testInputContainer"></div>');
                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;
        });