index.spec.tsx 1.3 KB

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