seenByList.spec.tsx 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. ConfigStore.init();
  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. ConfigStore.set('user', TestStubs.User());
  14. render(
  15. <SeenByList
  16. seenBy={[
  17. TestStubs.User({id: '2', name: 'jane'}),
  18. TestStubs.User({id: '3', name: 'john'}),
  19. ]}
  20. />
  21. );
  22. expect(screen.getByTitle('jane')).toBeInTheDocument();
  23. expect(screen.getByTitle('john')).toBeInTheDocument();
  24. });
  25. it('filters out the current user from list of users', function () {
  26. ConfigStore.set('user', TestStubs.User({id: '2', name: 'jane'}));
  27. render(
  28. <SeenByList
  29. seenBy={[
  30. TestStubs.User({id: '2', name: 'jane'}),
  31. TestStubs.User({id: '3', name: 'john'}),
  32. ]}
  33. />
  34. );
  35. expect(screen.queryByTitle('jane')).not.toBeInTheDocument();
  36. expect(screen.getByTitle('john')).toBeInTheDocument();
  37. });
  38. });