Skip to content

Commit

Permalink
fix(FEC-8940): cannot configure plugin by array (#222)
Browse files Browse the repository at this point in the history
iterating on array
  • Loading branch information
yairans authored Jun 11, 2019
1 parent f7fa3ac commit 0237207
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/common/plugins/plugins-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const removeUnevaluatedExpression = (obj = {}): Object =>
Object.entries(obj).reduce((product, [key, value]): Object => {
if (typeof value !== 'function' && Utils.Object.isObject(value)) {
product[key] = removeUnevaluatedExpression(value);
} else if (Array.isArray(value)) {
product[key] = value.filter(index => isValueEvaluated(index));
} else if (isValueEvaluated(value)) {
product[key] = value;
}
Expand Down
8 changes: 7 additions & 1 deletion test/src/common/plugins/plugins-config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ describe('evaluatePluginsConfig', function() {
const pluginsConfig = {
kava: {
myHandler: function() {},
myUnevaluatedConfig: '{{abc}}'
myUnevaluatedConfig: '{{abc}}',
myArray: [1, 'value', 0, true, '{{value}}', false]
}
};

Expand All @@ -30,4 +31,9 @@ describe('evaluatePluginsConfig', function() {
evaluatePluginsConfig(pluginsConfig, playerConfig);
pluginsConfig.kava.should.not.have.property('myUnevaluatedConfig');
});

it('should remove unevaluated plugins config from array', function() {
evaluatePluginsConfig(pluginsConfig, playerConfig);
pluginsConfig.kava.myArray.should.deep.equal([1, 'value', 0, true, false]);
});
});

0 comments on commit 0237207

Please sign in to comment.