FormField.test.tsx 781 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import { FormField, Props } from './FormField';
  4. const setup = (propOverrides?: Partial<Props>) => {
  5. const props: Props = {
  6. label: 'Test',
  7. labelWidth: 11,
  8. value: 10,
  9. onChange: jest.fn(),
  10. };
  11. Object.assign(props, propOverrides);
  12. return shallow(<FormField {...props} />);
  13. };
  14. describe('FormField', () => {
  15. it('should render component with default inputEl', () => {
  16. const wrapper = setup();
  17. expect(wrapper).toMatchSnapshot();
  18. });
  19. it('should render component with custom inputEl', () => {
  20. const wrapper = setup({
  21. inputEl: (
  22. <>
  23. <span>Input</span>
  24. <button>Ok</button>
  25. </>
  26. ),
  27. });
  28. expect(wrapper).toMatchSnapshot();
  29. });
  30. });