Skip to content

Commit

Permalink
fix tests and add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lms24 committed Sep 24, 2024
1 parent 4716e3b commit f40a005
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/core/test/lib/utils/traceData.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SentrySpan, getTraceData } from '../../../src/';
import * as SentryCoreCurrentScopes from '../../../src/currentScopes';
import * as SentryCoreExports from '../../../src/exports';
import * as SentryCoreTracing from '../../../src/tracing';
import * as SentryCoreSpanUtils from '../../../src/utils/spanUtils';

Expand All @@ -22,6 +23,10 @@ const mockedScope = {
} as any;

describe('getTraceData', () => {
beforeEach(() => {
jest.clearAllMocks();
jest.spyOn(SentryCoreExports, 'isEnabled').mockReturnValue(true);
});
it('returns the tracing data from the span, if a span is available', () => {
{
jest.spyOn(SentryCoreTracing, 'getDynamicSamplingContextFromSpan').mockReturnValueOnce({
Expand Down Expand Up @@ -139,6 +144,14 @@ describe('getTraceData', () => {

expect(traceData).toEqual({});
});

it('returns an empty object if the SDK is disabled', () => {
jest.spyOn(SentryCoreExports, 'isEnabled').mockReturnValueOnce(false);

const traceData = getTraceData();

expect(traceData).toEqual({});
});
});

describe('isValidBaggageString', () => {
Expand Down

0 comments on commit f40a005

Please sign in to comment.