Skip to content

Commit 1a8d4a3

Browse files
committed
Update spanTypes tests
1 parent fd97cc9 commit 1a8d4a3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/opentelemetry/src/utils/spanTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SpanContext, SpanKind, SpanStatus } from '@opentelemetry/api';
1+
import type { SpanKind, SpanStatus } from '@opentelemetry/api';
22
import type { ReadableSpan, TimedEvent } from '@opentelemetry/sdk-trace-node';
33

44
import type { AbstractSpan } from '../types';
@@ -54,7 +54,7 @@ export function spanHasName<SpanType extends AbstractSpan>(span: SpanType): span
5454
*/
5555
export function spanHasParentId<SpanType extends AbstractSpan>(
5656
span: SpanType,
57-
): span is SpanType & { spanContext?: SpanContext } {
57+
): span is SpanType {
5858
const castSpan = span as ReadableSpan;
5959
return !!castSpan.parentSpanContext?.spanId;
6060
}

packages/opentelemetry/test/utils/spanTypes.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ describe('spanTypes', () => {
4343
describe('spanHasParentId', () => {
4444
it.each([
4545
[{}, false],
46-
[{ parentSpanId: null }, false],
47-
[{ parentSpanId: 'TEST_PARENT_ID' }, true],
46+
[{ parentSpanContext: { spanId: null } }, false],
47+
[{ parentSpanContext: { spanId: 'TEST_PARENT_ID' } }, true],
4848
])('works with %p', (span, expected) => {
4949
const castSpan = span as unknown as Span;
5050
const actual = spanHasParentId(castSpan);
5151

5252
expect(actual).toBe(expected);
5353

5454
if (actual) {
55-
expect(castSpan.parentSpanId).toBeDefined();
55+
expect(castSpan.parentSpanContext?.spanId).toBeDefined();
5656
}
5757
});
5858
});

0 commit comments

Comments
 (0)