Daily iOS
TestingWalmart

Unit testing around a singleton

An app calls AuthManager.shared directly all over the code. How would you unit test the code that depends on this singleton?

final class AuthManager {
    static let shared = AuthManager()
    private(set) var token: String?
    func login(_ id: String) async throws { token = try await API.login(id) }
}

Submit