diff --git a/Tests/DependenciesTests/DependencyValuesTests.swift b/Tests/DependenciesTests/DependencyValuesTests.swift index 09ace466..95ce8c15 100644 --- a/Tests/DependenciesTests/DependencyValuesTests.swift +++ b/Tests/DependenciesTests/DependencyValuesTests.swift @@ -736,6 +736,14 @@ final class DependencyValuesTests: XCTestCase { XCTAssertEqual(now, Date(timeIntervalSinceReferenceDate: 1)) } + func testPrepareDependencies_setDependencyEndpoint() { + prepareDependencies { + $0[ClientWithEndpoint.self].get = { @Sendable in 42 } + } + @Dependency(ClientWithEndpoint.self) var client + XCTAssertEqual(client.get(), 42) + } + #if DEBUG && !os(Linux) && !os(WASI) && !os(Windows) func testPrepareDependencies_alreadyCached() { withDependencies { @@ -903,3 +911,10 @@ extension DependencyValues { set { self[FullDependency.self] = newValue } } } + +private struct ClientWithEndpoint: TestDependencyKey { + var get: @Sendable () -> Int + static var testValue: ClientWithEndpoint { + Self { 42 } + } +}