utils.spec.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type {NetworkSpan} from 'sentry/views/replays/types';
  2. import {getResourceTypes, getStatusTypes} from './utils';
  3. describe('getResourceTypes', () => {
  4. const SPAN_NAVIGATE = {op: 'navigation.navigate'} as NetworkSpan;
  5. const SPAN_FETCH = {op: 'resource.fetch'} as NetworkSpan;
  6. const SPAN_PUSH = {op: 'navigation.push'} as NetworkSpan;
  7. it('should return a sorted list of BreadcrumbType', () => {
  8. const spans = [SPAN_NAVIGATE, SPAN_FETCH, SPAN_PUSH];
  9. expect(getResourceTypes(spans)).toStrictEqual([
  10. 'fetch',
  11. 'navigation.navigate',
  12. 'navigation.push',
  13. ]);
  14. });
  15. it('should deduplicate BreadcrumbType', () => {
  16. const spans = [SPAN_FETCH, SPAN_FETCH];
  17. expect(getResourceTypes(spans)).toStrictEqual(['fetch']);
  18. });
  19. });
  20. describe('getStatusTypes', () => {
  21. const SPAN_200 = {data: {statusCode: 200}} as unknown as NetworkSpan;
  22. const SPAN_404 = {data: {statusCode: 404}} as unknown as NetworkSpan;
  23. const SPAN_UNKNOWN = {data: {statusCode: undefined}} as unknown as NetworkSpan;
  24. it('should return a sorted list of BreadcrumbType', () => {
  25. const spans = [SPAN_200, SPAN_404, SPAN_UNKNOWN];
  26. expect(getStatusTypes(spans)).toStrictEqual(['200', '404', 'unknown']);
  27. });
  28. it('should deduplicate BreadcrumbType', () => {
  29. const spans = [SPAN_200, SPAN_200];
  30. expect(getStatusTypes(spans)).toStrictEqual(['200']);
  31. });
  32. });