multiSelectField.spec.jsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {MultiSelectField} from 'sentry/components/deprecatedforms';
  3. import Form from 'sentry/components/deprecatedforms/form';
  4. describe('MultiSelectField', function () {
  5. describe('render()', function () {
  6. it('renders without form context', function () {
  7. const wrapper = mountWithTheme(
  8. <MultiSelectField
  9. options={[
  10. {label: 'a', value: 'a'},
  11. {label: 'b', value: 'b'},
  12. ]}
  13. name="fieldName"
  14. />
  15. );
  16. expect(wrapper).toSnapshot();
  17. });
  18. it('has the right value from props', function () {
  19. const wrapper = mountWithTheme(
  20. <MultiSelectField
  21. options={[
  22. {label: 'a', value: 'a'},
  23. {label: 'b', value: 'b'},
  24. ]}
  25. name="fieldName"
  26. value={['a']}
  27. />
  28. );
  29. expect(wrapper.find('StyledSelectControl').prop('value')).toEqual(['a']);
  30. });
  31. it('renders with form context', function () {
  32. const wrapper = mountWithTheme(
  33. <Form initialData={{fieldName: ['a', 'b']}}>
  34. <MultiSelectField
  35. options={[
  36. {label: 'a', value: 'a'},
  37. {label: 'b', value: 'b'},
  38. ]}
  39. name="fieldName"
  40. />
  41. </Form>
  42. );
  43. expect(wrapper.find('StyledSelectControl').prop('value')).toEqual(['a', 'b']);
  44. });
  45. });
  46. });