UsersActionBar.test.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import { UsersActionBar, Props } from './UsersActionBar';
  4. const setup = (propOverrides?: object) => {
  5. const props: Props = {
  6. searchQuery: '',
  7. setUsersSearchQuery: jest.fn(),
  8. showInvites: jest.fn(),
  9. pendingInvitesCount: 0,
  10. canInvite: false,
  11. externalUserMngLinkUrl: '',
  12. externalUserMngLinkName: '',
  13. };
  14. Object.assign(props, propOverrides);
  15. return shallow(<UsersActionBar {...props} />);
  16. };
  17. describe('Render', () => {
  18. it('should render component', () => {
  19. const wrapper = setup();
  20. expect(wrapper).toMatchSnapshot();
  21. });
  22. it('should render pending invites button', () => {
  23. const wrapper = setup({
  24. pendingInvitesCount: 5,
  25. });
  26. expect(wrapper).toMatchSnapshot();
  27. });
  28. it('should show invite button', () => {
  29. const wrapper = setup({
  30. canInvite: true,
  31. });
  32. expect(wrapper).toMatchSnapshot();
  33. });
  34. it('should show external user management button', () => {
  35. const wrapper = setup({
  36. externalUserMngLinkUrl: 'some/url',
  37. });
  38. expect(wrapper).toMatchSnapshot();
  39. });
  40. });