From e8d3f9bb40a62a7dc7532d60f65de7b0e6f00a2e Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Wed, 10 Feb 2016 18:59:12 +0000 Subject: [PATCH] Fixed Plugin.tags not initialising If the constructor is passed an object that doesn't have a `tags` key. --- src/gui/html/js/plugin.js | 2 +- src/tests/gui/html/js/test_plugin.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gui/html/js/plugin.js b/src/gui/html/js/plugin.js index da7db3f9..6d3102af 100644 --- a/src/gui/html/js/plugin.js +++ b/src/gui/html/js/plugin.js @@ -181,7 +181,7 @@ this.priority = obj.priority || 0; this.isPriorityGlobal = obj.isPriorityGlobal || false; this._messages = obj.messages || []; - this._tags = obj.tags; + this._tags = obj.tags || []; this._isDirty = obj.isDirty || false; /* UI state variables */ diff --git a/src/tests/gui/html/js/test_plugin.js b/src/tests/gui/html/js/test_plugin.js index 1f97d36b..6d8462b5 100644 --- a/src/tests/gui/html/js/test_plugin.js +++ b/src/tests/gui/html/js/test_plugin.js @@ -183,6 +183,24 @@ describe('Plugin', () => { plugin.isPriorityGlobal.should.be.true(); }); + it('should set tags value to an empty array if no key was passed', () => { + const plugin = new loot.Plugin({ name: 'test' }); + + plugin.tags.length.should.equal(0); + }); + + it('should set tags to passed key\'s value', () => { + const tags = [{ + name: 'Delev', + }]; + const plugin = new loot.Plugin({ + name: 'test', + tags, + }); + + plugin.tags.should.deepEqual(tags); + }); + it('should set id to the plugins name without spaces', () => { const plugin = new loot.Plugin({ name: 'test plugin name' });