diff options
Diffstat (limited to 'core/js/tests')
-rw-r--r-- | core/js/tests/specHelper.js | 3 | ||||
-rw-r--r-- | core/js/tests/specs/coreSpec.js | 31 |
2 files changed, 34 insertions, 0 deletions
diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js index 4111b6763d9..59c2a99645f 100644 --- a/core/js/tests/specHelper.js +++ b/core/js/tests/specHelper.js @@ -120,6 +120,9 @@ window.isPhantom = /phantom/i.test(navigator.userAgent); if (!OC.TestUtil) { OC.TestUtil = TestUtil; } + + // reset plugins + OC.Plugins._plugins = []; }); afterEach(function() { diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 2c5c22905b0..08395f4d4c2 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -655,5 +655,36 @@ describe('Core base tests', function() { ]); }); }); + describe('Plugins', function() { + var plugin; + + beforeEach(function() { + plugin = { + name: 'Some name', + attach: function(obj) { + obj.attached = true; + }, + + detach: function(obj) { + obj.attached = false; + } + }; + OC.Plugins.register('OC.Test.SomeName', plugin); + }); + it('attach plugin to object', function() { + var obj = {something: true}; + OC.Plugins.attach('OC.Test.SomeName', obj); + expect(obj.attached).toEqual(true); + OC.Plugins.detach('OC.Test.SomeName', obj); + expect(obj.attached).toEqual(false); + }); + it('only call handler for target name', function() { + var obj = {something: true}; + OC.Plugins.attach('OC.Test.SomeOtherName', obj); + expect(obj.attached).not.toBeDefined(); + OC.Plugins.detach('OC.Test.SomeOtherName', obj); + expect(obj.attached).not.toBeDefined(); + }); + }); }); |