Skip to content

Commit b2ba0ef

Browse files
committed
test(tracing): Add unit test for hasTracingEnabled
1 parent 3370277 commit b2ba0ef

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/tracing/test/utils.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
import { extractTraceparentData } from '../src/utils';
1+
import { extractTraceparentData, hasTracingEnabled } from '../src/utils';
2+
3+
describe('hasTracingEnabled', () => {
4+
const tracesSampler = () => 1;
5+
const tracesSampleRate = 1;
6+
it.each([
7+
['No options', undefined, false],
8+
['No tracesSampler or tracesSampleRate', {}, false],
9+
['With tracesSampler', { tracesSampler }, true],
10+
['With tracesSampleRate', { tracesSampleRate }, true],
11+
['With tracesSampler and tracesSampleRate', { tracesSampler, tracesSampleRate }, true],
12+
])(
13+
'%s',
14+
(_: string, input: Parameters<typeof hasTracingEnabled>[0], output: ReturnType<typeof hasTracingEnabled>) => {
15+
expect(hasTracingEnabled(input)).toBe(output);
16+
},
17+
);
18+
});
219

320
describe('extractTraceparentData', () => {
421
test('no sample', () => {

0 commit comments

Comments
 (0)