UNPKG

nestjs-otel

Version:
22 lines (21 loc) 899 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const api_1 = require("@opentelemetry/api"); const current_span_1 = require("./current-span"); describe("CurrentSpan Decorator", () => { const mockCtx = {}; afterEach(() => { jest.restoreAllMocks(); }); it("should return undefined if no span is active", () => { jest.spyOn(api_1.trace, "getSpan").mockReturnValue(undefined); const result = (0, current_span_1.currentSpanParamFactory)(undefined, mockCtx); expect(result).toBeUndefined(); }); it("should return the current span if one is active", () => { const mockSpan = { isRecording: () => true }; jest.spyOn(api_1.trace, "getSpan").mockReturnValue(mockSpan); const result = (0, current_span_1.currentSpanParamFactory)(undefined, mockCtx); expect(result).toBe(mockSpan); }); });