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' });