Input.spec.tsx 865 B

1234567891011121314151617181920212223242526272829303132
  1. import Input, { InputProps } from 'components/common/Input/Input';
  2. import React from 'react';
  3. import { render } from 'lib/testHelpers';
  4. const setupWrapper = (props?: Partial<InputProps>) => (
  5. <Input name="test" {...props} />
  6. );
  7. jest.mock('react-hook-form', () => ({
  8. useFormContext: () => ({
  9. register: jest.fn(),
  10. }),
  11. }));
  12. describe('Custom Input', () => {
  13. describe('with no icons', () => {
  14. it('matches the snapshot', () => {
  15. const component = render(setupWrapper());
  16. expect(component.baseElement).toMatchSnapshot();
  17. });
  18. });
  19. describe('with icons', () => {
  20. it('matches the snapshot', () => {
  21. const component = render(
  22. setupWrapper({
  23. leftIcon: 'fas fa-address-book',
  24. rightIcon: 'fas fa-address-book',
  25. })
  26. );
  27. expect(component.baseElement).toMatchSnapshot();
  28. });
  29. });
  30. });