auditLogView.spec.jsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React from 'react';
  2. import {shallow, mount} from 'enzyme';
  3. import {Client} from 'app/api';
  4. import OrganizationAuditLog from 'app/views/settings/organizationAuditLog';
  5. jest.mock('jquery');
  6. describe('OrganizationAuditLog', function() {
  7. let org = TestStubs.Organization();
  8. const ENDPOINT = `/organizations/${org.slug}/audit-logs/`;
  9. beforeEach(function() {
  10. Client.clearMockResponses();
  11. Client.addMockResponse({
  12. url: ENDPOINT,
  13. body: TestStubs.AuditLogs(),
  14. });
  15. });
  16. it('renders', function(done) {
  17. let wrapper = shallow(
  18. <OrganizationAuditLog location={{query: ''}} params={{orgId: org.slug}} />,
  19. TestStubs.routerContext()
  20. );
  21. wrapper.setState({loading: false});
  22. wrapper.update();
  23. setTimeout(() => {
  24. wrapper.update();
  25. expect(wrapper).toMatchSnapshot();
  26. done();
  27. });
  28. });
  29. it('displays whether an action was done by a superuser', function() {
  30. let wrapper = mount(
  31. <OrganizationAuditLog location={{query: ''}} params={{orgId: org.slug}} />,
  32. TestStubs.routerContext()
  33. );
  34. expect(
  35. wrapper
  36. .find('div[data-test-id="actor-name"]')
  37. .at(0)
  38. .text()
  39. ).toEqual(expect.stringContaining('(Sentry Staff)'));
  40. expect(
  41. wrapper
  42. .find('div[data-test-id="actor-name"]')
  43. .at(1)
  44. .text()
  45. ).toEqual(expect.not.stringContaining('(Sentry Staff)'));
  46. });
  47. });