genericField.spec.jsx 934 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import React from 'react';
  2. import {shallow} from 'enzyme';
  3. import {GenericField, FormState} from 'app/components/forms';
  4. describe('GenericField', function() {
  5. it('renders text as TextInput', function() {
  6. let wrapper = shallow(
  7. <GenericField
  8. formState={FormState.READY}
  9. config={{
  10. name: 'field-name',
  11. label: 'field label',
  12. type: 'text',
  13. }}
  14. />
  15. );
  16. expect(wrapper).toMatchSnapshot();
  17. expect(wrapper.name()).toEqual('TextField');
  18. });
  19. it('renders text with choices as SelectCreatableField', function() {
  20. let wrapper = shallow(
  21. <GenericField
  22. formState={FormState.READY}
  23. config={{
  24. name: 'field-name',
  25. label: 'field label',
  26. type: 'text',
  27. choices: [],
  28. }}
  29. />
  30. );
  31. expect(wrapper).toMatchSnapshot();
  32. expect(wrapper.name()).toEqual('SelectCreatableField');
  33. });
  34. });