Testing Closures Using Swift Testing

if someone is looking to test closures using Swift Testing

1
2
3
4
5
6
7
8
9
10
@Test func handleURLMetadata() async throws {
        let url = try #require(URL(string: "https://www.doordash.com/backendYetToDecide"))
        await withCheckedContinuation { continuation in
            consumerRouter.presentUsingCompletionClosure = { routableType, routableStyle, _ in
                #expect(...)
                continuation.resume()
            }
            linkHandler.handle(url)
        }
    }