crashReports.spec.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import {
  3. formatStoreCrashReports,
  4. getStoreCrashReportsValues,
  5. } from 'sentry/utils/crashReports';
  6. describe('crashReportsUtils', () => {
  7. it('returns correct values for organization scope', () => {
  8. expect(getStoreCrashReportsValues(0)).toEqual([0, 1, 5, 10, 20, 50, 100, -1]);
  9. });
  10. it('returns correct values for project scope', () => {
  11. expect(getStoreCrashReportsValues(1)).toEqual([null, 0, 1, 5, 10, 20, 50, 100, -1]);
  12. });
  13. it('formats basic values', () => {
  14. expect(formatStoreCrashReports(-1)).toBe('Unlimited');
  15. expect(formatStoreCrashReports(0)).toBe('Disabled');
  16. });
  17. it('formats per issue values', () => {
  18. render(<div data-test-id="subject">{formatStoreCrashReports(10)}</div>);
  19. expect(screen.getByTestId('subject')).toHaveTextContent('10 per issue');
  20. });
  21. it('formats with org inheritance', () => {
  22. render(<div data-test-id="subject">{formatStoreCrashReports(null, 5)}</div>);
  23. expect(screen.getByTestId('subject')).toHaveTextContent(
  24. 'Inherit organization settings (5 per issue)'
  25. );
  26. });
  27. it('formats with org inheritance disabled', () => {
  28. render(<div data-test-id="subject">{formatStoreCrashReports(null, 0)}</div>);
  29. expect(screen.getByTestId('subject')).toHaveTextContent(
  30. 'Inherit organization settings (Disabled)'
  31. );
  32. });
  33. });