| 1 |
import renderer from 'react-test-renderer'; |
| 2 |
import validator from '@rjsf/validator-ajv8'; |
| 3 |
import { RJSFSchema } from '@rjsf/utils'; |
| 4 |
import { formTests, SELECT_CUSTOMIZE } from '@rjsf/snapshot-tests'; |
| 5 |
|
| 6 |
import '../__mocks__/matchMedia.mock'; |
| 7 |
import Form from '../src'; |
| 8 |
|
| 9 |
formTests(Form, { |
| 10 |
[SELECT_CUSTOMIZE]: { |
| 11 |
createNodeMock: (element) => { |
| 12 |
if (element.type === 'span' && element.props['aria-hidden']) { |
| 13 |
// the `rc-select` MultipleSelector code expects a ref for this span to exist, so use the feature of |
| 14 |
// react-test-renderer to create one |
| 15 |
// See: https://reactjs.org/docs/test-renderer.html#ideas |
| 16 |
return { scrollWidth: 100 }; |
| 17 |
} |
| 18 |
return null; |
| 19 |
}, |
| 20 |
}, |
| 21 |
}); |
| 22 |
|
| 23 |
describe('antd specific tests', () => { |
| 24 |
test('descriptionLocation tooltip in formContext', () => { |
| 25 |
const schema: RJSFSchema = { |
| 26 |
type: 'object', |
| 27 |
properties: { |
| 28 |
'my-field': { |
| 29 |
type: 'string', |
| 30 |
description: 'some description', |
| 31 |
}, |
| 32 |
}, |
| 33 |
}; |
| 34 |
const formContext = { descriptionLocation: 'tooltip' }; |
| 35 |
const tree = renderer.create(<Form schema={schema} validator={validator} formContext={formContext} />).toJSON(); |
| 36 |
expect(tree).toMatchSnapshot(); |
| 37 |
}); |
| 38 |
}); |