diff --git a/Tests/DatadogTests/Datadog/DatadogCore/DatadogContextProviderTests.swift b/Tests/DatadogTests/Datadog/DatadogCore/DatadogContextProviderTests.swift index 77e34b0cdd..6c25f34679 100644 --- a/Tests/DatadogTests/Datadog/DatadogCore/DatadogContextProviderTests.swift +++ b/Tests/DatadogTests/Datadog/DatadogCore/DatadogContextProviderTests.swift @@ -68,6 +68,47 @@ class DatadogContextProviderTests: XCTestCase { XCTAssertEqual(context.carrierInfo, carrierInfo) } + func testPublishNewContextOnValueChange() throws { + let expectation = self.expectation(description: "publish new context") + expectation.expectedFulfillmentCount = 3 + + // Given + let serverOffsetPublisher = ContextValuePublisherMock(initialValue: 0) + + let provider = DatadogContextProvider(context: context) + provider.subscribe(\.serverTimeOffset, to: serverOffsetPublisher) + + provider.publish { _ in + expectation.fulfill() + } + + // When + (0..