index.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import SessionHistory from 'sentry/views/settings/account/accountSecurity/sessionHistory';
  5. const ENDPOINT = '/users/me/ips/';
  6. describe('AccountSecuritySessionHistory', function () {
  7. const {routerProps} = initializeOrg();
  8. afterEach(function () {
  9. MockApiClient.clearMockResponses();
  10. });
  11. it('renders an ip address', async function () {
  12. MockApiClient.addMockResponse({
  13. url: ENDPOINT,
  14. body: [
  15. {
  16. countryCode: null,
  17. regionCode: null,
  18. lastSeen: '2018-09-07T18:24:29.401Z',
  19. ipAddress: '127.0.0.1',
  20. id: '1',
  21. firstSeen: '2018-09-07T17:59:14.642Z',
  22. },
  23. {
  24. countryCode: 'US',
  25. regionCode: 'CA',
  26. lastSeen: '2018-09-07T18:17:05.087Z',
  27. ipAddress: '192.168.0.1',
  28. id: '3',
  29. firstSeen: '2018-09-07T18:17:05.087Z',
  30. },
  31. ],
  32. });
  33. render(<SessionHistory {...routerProps} />, {context: RouterContextFixture()});
  34. expect(await screen.findByText('127.0.0.1')).toBeInTheDocument();
  35. expect(screen.getByText('192.168.0.1')).toBeInTheDocument();
  36. expect(screen.getByText('US (CA)')).toBeInTheDocument();
  37. });
  38. });