From 2743af0da22abf9cb84c8653cc5c630d93e67a06 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 17 Jun 2020 10:12:28 -0400 Subject: [PATCH] cleanup --- packages/react/src/profiler.tsx | 6 +++--- packages/react/test/profiler.test.tsx | 16 +++++----------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/react/src/profiler.tsx b/packages/react/src/profiler.tsx index 5fab8b4c3cd3..8ef7d6966f63 100644 --- a/packages/react/src/profiler.tsx +++ b/packages/react/src/profiler.tsx @@ -50,7 +50,7 @@ function pushActivity(name: string, op: string): number | null { /** * popActivity removes a React activity. - * Is a no-op if invalid Tracing integration or invalid activity id. + * Is a no-op if Tracing integration is not valid. * @param activity id of activity that is being popped */ function popActivity(activity: number | null): void { @@ -64,11 +64,11 @@ function popActivity(activity: number | null): void { /** * Obtain a span given an activity id. - * Is a no-op if invalid Tracing integration. + * Is a no-op if Tracing integration is not valid. * @param activity activity id associated with obtained span */ function getActivitySpan(activity: number | null): Span | undefined { - if (globalTracingIntegration === null) { + if (activity === null || globalTracingIntegration === null) { return undefined; } diff --git a/packages/react/test/profiler.test.tsx b/packages/react/test/profiler.test.tsx index cd65d68fbd0b..0da9d9545099 100644 --- a/packages/react/test/profiler.test.tsx +++ b/packages/react/test/profiler.test.tsx @@ -4,24 +4,18 @@ import { renderHook } from '@testing-library/react-hooks'; import * as React from 'react'; import { UNKNOWN_COMPONENT, useProfiler, withProfiler } from '../src/profiler'; -/*( -for key in SENTRY_FEATURES: - SENTRY_FEATURES[key] = True -SENTRY_APM_SAMPLING = 1 -)*/ const TEST_SPAN_ID = '518999beeceb49af'; +const TEST_TIMESTAMP = '123456'; const mockStartChild = jest.fn((spanArgs: SpanContext) => ({ ...spanArgs })); -const TEST_SPAN = { - spanId: TEST_SPAN_ID, - startChild: mockStartChild, -}; -const TEST_TIMESTAMP = '123456'; const mockPushActivity = jest.fn().mockReturnValue(1); const mockPopActivity = jest.fn(); const mockLoggerWarn = jest.fn(); -const mockGetActivitySpan = jest.fn().mockReturnValue(TEST_SPAN); +const mockGetActivitySpan = jest.fn().mockReturnValue({ + spanId: TEST_SPAN_ID, + startChild: mockStartChild, +}); jest.mock('@sentry/utils', () => ({ logger: {