diff options
Diffstat (limited to 'apps/files/tests/js/fileactionsSpec.js')
-rw-r--r-- | apps/files/tests/js/fileactionsSpec.js | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js index 355761afa01..f464800730a 100644 --- a/apps/files/tests/js/fileactionsSpec.js +++ b/apps/files/tests/js/fileactionsSpec.js @@ -21,7 +21,7 @@ describe('OCA.Files.FileActions tests', function() { var $filesTable, fileList; - var FileActions; + var FileActions; beforeEach(function() { // init horrible parameters @@ -36,6 +36,7 @@ describe('OCA.Files.FileActions tests', function() { }); afterEach(function() { FileActions = null; + fileList.destroy(); fileList = undefined; $('#dir, #permissions, #filestable').remove(); }); @@ -192,4 +193,54 @@ describe('OCA.Files.FileActions tests', function() { context = actionStub.getCall(0).args[1]; expect(context.dir).toEqual('/somepath'); }); + describe('events', function() { + var clock; + beforeEach(function() { + clock = sinon.useFakeTimers(); + }); + afterEach(function() { + clock.restore(); + }); + it('notifies update event handlers once after multiple changes', function() { + var actionStub = sinon.stub(); + var handler = sinon.stub(); + FileActions.addUpdateListener(handler); + FileActions.register( + 'all', + 'Test', + OC.PERMISSION_READ, + OC.imagePath('core', 'actions/test'), + actionStub + ); + FileActions.register( + 'all', + 'Test2', + OC.PERMISSION_READ, + OC.imagePath('core', 'actions/test'), + actionStub + ); + expect(handler.calledTwice).toEqual(true); + }); + it('does not notifies update event handlers after unregistering', function() { + var actionStub = sinon.stub(); + var handler = sinon.stub(); + FileActions.addUpdateListener(handler); + FileActions.removeUpdateListener(handler); + FileActions.register( + 'all', + 'Test', + OC.PERMISSION_READ, + OC.imagePath('core', 'actions/test'), + actionStub + ); + FileActions.register( + 'all', + 'Test2', + OC.PERMISSION_READ, + OC.imagePath('core', 'actions/test'), + actionStub + ); + expect(handler.notCalled).toEqual(true); + }); + }); }); |