Skip to content

Commit

Permalink
fix(utils): uses a recursive convertToPSParam to get converted types …
Browse files Browse the repository at this point in the history
…inside array
  • Loading branch information
ricardo-jsx committed Nov 12, 2019
1 parent b0a0f7f commit 33e7970
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const convertToPSParam = val => {
case 'Number':
return val;
case 'Array':
return val;
return val.map(convertToPSParam);
case 'Object':
return `@${JSON.stringify(val).replace(/:/g, '=').replace(/,/g, ';')}`;
case 'Boolean':
Expand Down
10 changes: 10 additions & 0 deletions test/others.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const {
convertToPSParam,
convertToPSOption,
} = require('../lib/utils');

const {
PS_PROC_ERROR,
PS_ARG_MISS_ERROR,
Expand Down Expand Up @@ -44,6 +45,15 @@ describe('Utils', () => {
});

describe('convert', () => {
it('convert an array to a PS param', () => {
const param = [true, "String with spaces", { key: 123 }];
const convertedParam = convertToPSParam(param);

expect(convertedParam[0]).to.equal("$True");
expect(convertedParam[1]).to.equal('"String with spaces"');
expect(convertedParam[2]).to.equal('@{"key"=123}');
});

it('convert a JS param to a PS param');
it('convert a JS option to a PS option');
});
Expand Down

0 comments on commit 33e7970

Please sign in to comment.