accountSecuritySessionHistory.spec.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import {Client} from 'app/api';
  4. import AccountSecuritySessionHistory from 'app/views/settings/account/accountSecurity/accountSecuritySessionHistory';
  5. const ENDPOINT = '/users/me/ips/';
  6. const ORG_ENDPOINT = '/organizations/';
  7. describe('AccountSecuritySessionHistory', function() {
  8. beforeEach(function() {
  9. Client.clearMockResponses();
  10. Client.addMockResponse({
  11. url: ORG_ENDPOINT,
  12. body: TestStubs.Organizations(),
  13. });
  14. });
  15. it('renders an ip address', async function() {
  16. Client.addMockResponse({
  17. url: ENDPOINT,
  18. body: [
  19. {
  20. countryCode: null,
  21. regionCode: null,
  22. lastSeen: '2018-09-07T18:24:29.401Z',
  23. ipAddress: '127.0.0.1',
  24. id: '1',
  25. firstSeen: '2018-09-07T17:59:14.642Z',
  26. },
  27. {
  28. countryCode: 'US',
  29. regionCode: 'CA',
  30. lastSeen: '2018-09-07T18:17:05.087Z',
  31. ipAddress: '192.168.0.1',
  32. id: '3',
  33. firstSeen: '2018-09-07T18:17:05.087Z',
  34. },
  35. ],
  36. });
  37. const wrapper = mount(<AccountSecuritySessionHistory />, TestStubs.routerContext());
  38. wrapper.update();
  39. await tick();
  40. expect(wrapper.find('SessionRow')).toHaveLength(2);
  41. });
  42. });