Skip to content

Commit f40a005

Browse files
committed
fix tests and add unit test
1 parent 4716e3b commit f40a005

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/core/test/lib/utils/traceData.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SentrySpan, getTraceData } from '../../../src/';
22
import * as SentryCoreCurrentScopes from '../../../src/currentScopes';
3+
import * as SentryCoreExports from '../../../src/exports';
34
import * as SentryCoreTracing from '../../../src/tracing';
45
import * as SentryCoreSpanUtils from '../../../src/utils/spanUtils';
56

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

2425
describe('getTraceData', () => {
26+
beforeEach(() => {
27+
jest.clearAllMocks();
28+
jest.spyOn(SentryCoreExports, 'isEnabled').mockReturnValue(true);
29+
});
2530
it('returns the tracing data from the span, if a span is available', () => {
2631
{
2732
jest.spyOn(SentryCoreTracing, 'getDynamicSamplingContextFromSpan').mockReturnValueOnce({
@@ -139,6 +144,14 @@ describe('getTraceData', () => {
139144

140145
expect(traceData).toEqual({});
141146
});
147+
148+
it('returns an empty object if the SDK is disabled', () => {
149+
jest.spyOn(SentryCoreExports, 'isEnabled').mockReturnValueOnce(false);
150+
151+
const traceData = getTraceData();
152+
153+
expect(traceData).toEqual({});
154+
});
142155
});
143156

144157
describe('isValidBaggageString', () => {

0 commit comments

Comments
 (0)