Skip to content

Commit

Permalink
Merge pull request #160 from schemepunk/delimit-fix
Browse files Browse the repository at this point in the history
fix(delimit): delimit values fails if value is empty
  • Loading branch information
thebruce authored Jun 20, 2019
2 parents 75a9df7 + dbf656d commit 9e7cfc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions __tests__/plugins/transform/delimitValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ describe('Delimit Values tests', () => {
};
expect(await delimitValues.transform(value)).toBe('test1-test2-test3');
});
test('no value is ok.', async () => {
// Emulate a custom option from a scheme.
delimitValues.options = {
sourceDelimiter: '-'
};
expect(await delimitValues.transform()).toBe('');
});
});
2 changes: 1 addition & 1 deletion lib/plugins/transform/delimitValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = superclass => class extends superclass {
* @param value
* A value to perform a transformation upon.
*/
async transform(value) {
async transform(value = []) {
const delimiter = _.get(this, 'options.sourceDelimiter', ',');
const tempValue = value.join(delimiter);
// Call super.transform and pass along the new value to honor composition.
Expand Down

0 comments on commit 9e7cfc5

Please sign in to comment.