teams.spec.jsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {act, render} from 'sentry-test/reactTestingLibrary';
  2. import TeamStore from 'sentry/stores/teamStore';
  3. import Teams from 'sentry/utils/teams';
  4. describe('utils.teams', function () {
  5. const renderer = jest.fn(() => null);
  6. const createWrapper = props => render(<Teams {...props}>{renderer}</Teams>);
  7. beforeEach(function () {
  8. TeamStore.loadInitialData([
  9. TestStubs.Team({id: '1', slug: 'bar'}),
  10. TestStubs.Team({id: '2', slug: 'foo'}),
  11. ]);
  12. renderer.mockClear();
  13. });
  14. afterEach(function () {
  15. act(() => void TeamStore.loadInitialData([]));
  16. });
  17. it('sends projects to children', function () {
  18. createWrapper();
  19. expect(renderer).toHaveBeenCalledWith(
  20. expect.objectContaining({
  21. fetching: false,
  22. hasMore: null,
  23. fetchError: null,
  24. teams: [
  25. expect.objectContaining({
  26. id: '1',
  27. slug: 'bar',
  28. }),
  29. expect.objectContaining({
  30. id: '2',
  31. slug: 'foo',
  32. }),
  33. ],
  34. })
  35. );
  36. });
  37. });