multipleCheckboxField.spec.jsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {render} from 'sentry-test/reactTestingLibrary';
  2. import {MultipleCheckboxField} from 'sentry/components/deprecatedforms';
  3. import Form from 'sentry/components/forms/form';
  4. import FormModel from 'sentry/components/forms/model';
  5. describe('MultipleCheckboxField', function () {
  6. it('renders without form context', function () {
  7. const {container} = render(
  8. <MultipleCheckboxField
  9. name="fieldName"
  10. choices={[
  11. ['1', 'On'],
  12. ['2', 'Off'],
  13. ]}
  14. value={['1']}
  15. />
  16. );
  17. expect(container).toSnapshot();
  18. });
  19. it('renders with form context', function () {
  20. const model = new FormModel({initialData: {fieldName: ['1']}});
  21. const {container} = render(
  22. <Form value={model}>
  23. <MultipleCheckboxField
  24. name="fieldName"
  25. choices={[
  26. ['1', 'On'],
  27. ['2', 'Off'],
  28. ]}
  29. />
  30. </Form>
  31. );
  32. expect(container).toSnapshot();
  33. expect(model.fields.get('fieldName')).toEqual(['1']);
  34. });
  35. });