Skip to content

Commit

Permalink
fix(utils): close #37, fix object params (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
BuptStEve authored Jul 25, 2019
1 parent 13624ab commit 759a618
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tua-api",
"version": "1.3.2",
"version": "1.3.3",
"description": "🏗 A common tool helps converting configs to api functions",
"main": "dist/TuaApi.cjs.js",
"module": "dist/TuaApi.esm.js",
Expand Down
4 changes: 3 additions & 1 deletion src/utils/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ const getDefaultParamObj = ({
}
}

return { [key]: val }
const returnVal = typeof val === 'object' ? '' : val

return { [key]: returnVal }
}),
reduce(merge, commonParams)
)(params)
Expand Down
4 changes: 4 additions & 0 deletions test/__tests__/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ test('getDefaultParamObj', () => {
commonParams: { c: '3' },
})).toEqual({ b: '2', c: '3' })

expect(getDefaultParamObj({
params: { a: { required: false } },
})).toEqual({ a: '' })

expect(() => getDefaultParamObj({
params: { b: { required: true } },
apiName: 'steve',
Expand Down

0 comments on commit 759a618

Please sign in to comment.