diff options
author | Robin Appelman <robin@icewind.nl> | 2014-12-12 11:43:31 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2014-12-12 11:43:31 +0100 |
commit | 3bf0922b1337115c7cfc8a03547bc2d7d0d9fa69 (patch) | |
tree | 5c594dff36a1210b12dbb05558f50310819a5325 /core/js/tests/specs | |
parent | c451d99daae86290281806d0e8cdcfcfcf451412 (diff) | |
parent | bf887eca8bac04cbbd2f1bd5197017c0e0583edd (diff) | |
download | nextcloud-server-3bf0922b1337115c7cfc8a03547bc2d7d0d9fa69.tar.gz nextcloud-server-3bf0922b1337115c7cfc8a03547bc2d7d0d9fa69.zip |
Merge pull request #12527 from owncloud/js-pluginsystem
Simple Plugin system for Javascript
Diffstat (limited to 'core/js/tests/specs')
-rw-r--r-- | core/js/tests/specs/coreSpec.js | 31 |
1 files changed, 31 insertions, 0 deletions
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(); + }); + }); }); |