seenByList.spec.jsx 1.5 KB

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