Skip to content

Commit

Permalink
test(@uform/utils): add setIn testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Jul 4, 2019
1 parent cc72a13 commit 67a82e6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/utils/src/__tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ test('test accessor with large path', () => {
expect(isEqual(getIn(value, 'array.0.[aa,bb]'), [123, 321])).toBeTruthy()
})

test('test setIn auto create array', () => {
const value = {}
setIn(value, 'array.0.bb.2', 'hello world')
expect(
isEqual(value, {
array: [
{
bb: [undefined, undefined, 'hello world']
}
]
})
).toBeTruthy()
})

test('destruct getIn', () => {
// getIn 通过解构表达式从扁平数据转为复合嵌套数据
const value = { a: { b: { c: 2, d: 333 } } }
Expand Down

0 comments on commit 67a82e6

Please sign in to comment.