Fixed Plugin.tags not initialising

If the constructor is passed an object that doesn't have a `tags` key.
This commit is contained in:
Oliver Hamlet
2016-03-05 11:49:26 +00:00
parent d1fc5df051
commit e8d3f9bb40
2 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -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 */
+18
View File
@@ -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' });