Skip to content

Commit

Permalink
test(core): nested reaction should recall the tracker (#1696)
Browse files Browse the repository at this point in the history
  • Loading branch information
javahuang authored Jun 30, 2021
1 parent 948ec73 commit a6b8104
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/core/src/__tests__/field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1079,3 +1079,37 @@ test('array path calculation with void index and void wrapper', async () => {
)
expect(input.path.toString()).toEqual('array_in_layout.0')
})

test('reaction in reaction', () => {
const form = attach(createForm())
const void_ = attach(
form.createVoidField({
name: 'void',
})
)
attach(
form.createField({
name: 'field1',
basePath: 'void',
initialValue: 123,
})
)
const field2 = attach(
form.createField({
name: 'field2',
basePath: 'void',
initialValue: 456,
reactions: (field) => {
const f1 = field.query('field1')
if (f1.get('value') === 123) {
field.display = 'visible'
} else {
field.display = 'none'
}
},
})
)
void_.setDisplay('none')
expect(field2.value).toEqual(undefined)
expect(field2.display).toEqual('none')
})

0 comments on commit a6b8104

Please sign in to comment.