TeamSettings.test.tsx 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import { Props, TeamSettings } from './TeamSettings';
  4. import { getMockTeam } from './__mocks__/teamMocks';
  5. const setup = (propOverrides?: object) => {
  6. const props: Props = {
  7. team: getMockTeam(),
  8. updateTeam: jest.fn(),
  9. };
  10. Object.assign(props, propOverrides);
  11. const wrapper = shallow(<TeamSettings {...props} />);
  12. const instance = wrapper.instance() as TeamSettings;
  13. return {
  14. wrapper,
  15. instance,
  16. };
  17. };
  18. describe('Render', () => {
  19. it('should render component', () => {
  20. const { wrapper } = setup();
  21. expect(wrapper).toMatchSnapshot();
  22. });
  23. });
  24. describe('Functions', () => {
  25. it('should update team', () => {
  26. const { instance } = setup();
  27. const mockEvent = { preventDefault: jest.fn() };
  28. instance.setState({
  29. name: 'test11',
  30. });
  31. instance.onUpdate(mockEvent);
  32. expect(instance.props.updateTeam).toHaveBeenCalledWith('test11', 'test@test.com');
  33. });
  34. });