seenByList.spec.jsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import SeenByList from 'sentry/components/seenByList';
  3. import ConfigStore from 'sentry/stores/configStore';
  4. describe('SeenByList', function () {
  5. beforeEach(function () {
  6. jest.spyOn(ConfigStore, 'get').mockImplementation(() => ({}));
  7. });
  8. it('should return null if seenBy is falsy', function () {
  9. const {container} = render(<SeenByList />);
  10. expect(container).toBeEmptyDOMElement();
  11. });
  12. it('should return a list of each user that saw', function () {
  13. render(
  14. <SeenByList
  15. seenBy={[
  16. {id: '1', email: 'jane@example.com'},
  17. {id: '2', email: 'john@example.com'},
  18. ]}
  19. />
  20. );
  21. expect(screen.getByTitle('jane@example.com')).toBeInTheDocument();
  22. expect(screen.getByTitle('john@example.com')).toBeInTheDocument();
  23. });
  24. it('filters out the current user from list of users', function () {
  25. jest
  26. .spyOn(ConfigStore, 'get')
  27. .mockImplementation(() => ({id: '1', email: 'jane@example.com'}));
  28. render(
  29. <SeenByList
  30. seenBy={[
  31. {id: '1', email: 'jane@example.com'},
  32. {id: '2', email: 'john@example.com'},
  33. ]}
  34. />
  35. );
  36. expect(screen.queryByTitle('jane@example.com')).not.toBeInTheDocument();
  37. expect(screen.getByTitle('john@example.com')).toBeInTheDocument();
  38. });
  39. });