teamBadge.spec.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {act, render, screen} from 'sentry-test/reactTestingLibrary';
  2. import {TeamBadge} from 'sentry/components/idBadge/teamBadge';
  3. import TeamStore from 'sentry/stores/teamStore';
  4. describe('TeamBadge', function () {
  5. beforeEach(() => {
  6. TeamStore.init();
  7. });
  8. afterEach(() => {
  9. TeamStore.teardown();
  10. });
  11. it('renders with Avatar and team name', function () {
  12. render(<TeamBadge team={TestStubs.Team()} />);
  13. expect(screen.getByTestId('badge-styled-avatar')).toBeInTheDocument();
  14. expect(screen.getByText(/#team-slug/)).toBeInTheDocument();
  15. });
  16. it('listens for avatar changes from TeamStore', async function () {
  17. const team = TestStubs.Team();
  18. render(<TeamBadge team={team} />);
  19. act(() => {
  20. TeamStore.onUpdateSuccess(team.id, {
  21. ...team,
  22. slug: 'new-team-slug',
  23. });
  24. });
  25. expect(await screen.findByText(/#new-team-slug/)).toBeInTheDocument();
  26. });
  27. it('updates state from props', async function () {
  28. const team = TestStubs.Team();
  29. const {rerender} = render(<TeamBadge team={team} />);
  30. rerender(<TeamBadge team={TestStubs.Team({slug: 'new-team-slug'})} />);
  31. expect(await screen.findByText(/#new-team-slug/)).toBeInTheDocument();
  32. });
  33. });