seenByList.spec.jsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import SeenByList from 'app/components/seenByList';
  3. import ConfigStore from 'app/stores/configStore';
  4. describe('SeenByList', function () {
  5. beforeEach(function () {
  6. jest.spyOn(ConfigStore, 'get').mockImplementation(() => ({}));
  7. });
  8. afterEach(function () {});
  9. it('should return null if seenBy is falsy', function () {
  10. const wrapper = mountWithTheme(<SeenByList />);
  11. expect(wrapper.children()).toHaveLength(0);
  12. });
  13. it('should return a list of each user that saw', function () {
  14. const wrapper = mountWithTheme(
  15. <SeenByList
  16. seenBy={[
  17. {id: '1', email: 'jane@example.com'},
  18. {id: '2', email: 'john@example.com'},
  19. ]}
  20. />
  21. );
  22. expect(wrapper.find('IconShow')).toHaveLength(1);
  23. expect(wrapper.find('AvatarList')).toHaveLength(1);
  24. expect(wrapper.find('UserAvatar')).toHaveLength(2);
  25. });
  26. it('filters out the current user from list of users', function () {
  27. jest
  28. .spyOn(ConfigStore, 'get')
  29. .mockImplementation(() => ({id: '1', email: 'jane@example.com'}));
  30. const wrapper = mountWithTheme(
  31. <SeenByList
  32. seenBy={[
  33. {id: '1', email: 'jane@example.com'},
  34. {id: '2', email: 'john@example.com'},
  35. ]}
  36. />
  37. );
  38. expect(wrapper.find('IconShow')).toHaveLength(1);
  39. expect(wrapper.find('AvatarList')).toHaveLength(1);
  40. expect(wrapper.find('UserAvatar')).toHaveLength(1);
  41. expect(wrapper.find('LetterAvatar').prop('displayName')).toBe('john@example.com');
  42. });
  43. });