genericField.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import GenericField from 'sentry/components/deprecatedforms/genericField';
  3. import FormState from 'sentry/components/forms/state';
  4. describe('GenericField', function () {
  5. it('renders text as TextInput', function () {
  6. render(
  7. <GenericField
  8. formState={FormState.READY}
  9. formData={{name: 'foo'}}
  10. onChange={jest.fn()}
  11. config={{
  12. name: 'field-name',
  13. label: 'field label',
  14. type: 'text',
  15. placeholder: 'field placeholder',
  16. help: 'field help',
  17. required: true,
  18. choices: [],
  19. default: '',
  20. readonly: true,
  21. }}
  22. />
  23. );
  24. expect(screen.getByRole('textbox')).toBeInTheDocument();
  25. });
  26. it('renders text with choices as SelectCreatableField', function () {
  27. render(
  28. <GenericField
  29. formState={FormState.READY}
  30. formData={{name: 'foo'}}
  31. onChange={jest.fn()}
  32. config={{
  33. name: 'field-name',
  34. label: 'field label',
  35. type: 'text',
  36. placeholder: 'field placeholder',
  37. help: 'field help',
  38. required: true,
  39. choices: [],
  40. default: '',
  41. readonly: true,
  42. }}
  43. />
  44. );
  45. expect(screen.getByRole('textbox')).toHaveAttribute('aria-autocomplete', 'list');
  46. });
  47. });