-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix bug that async schema default property is not work - fix bug that visible property is not work by setFieldState when FormInit
- Loading branch information
Showing
4 changed files
with
119 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react' | ||
import SchemaForm, { Field, registerFormField, connect } from '../index' | ||
import { render } from 'react-testing-library' | ||
|
||
beforeEach(() => { | ||
registerFormField('string', connect()(props => <div>{props.value}</div>)) | ||
}) | ||
|
||
test('set visible by setFieldState', async () => { | ||
const TestComponent = () => { | ||
return ( | ||
<SchemaForm | ||
effects={($, { setFieldState }) => { | ||
$('onFormInit').subscribe(() => { | ||
setFieldState('aa', state => { | ||
state.visible = false | ||
}) | ||
}) | ||
}} | ||
> | ||
<Field type='string' name='aa' default='123321' /> | ||
</SchemaForm> | ||
) | ||
} | ||
|
||
const { queryByText } = render(<TestComponent />) | ||
|
||
await sleep(33) | ||
expect(queryByText('123321')).toBeNull() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters