Created
July 24, 2021 07:41
-
-
Save ykpoh/5696afb67bb61dc633e676d29d70a307 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
@testable import SpaceXLaunch | |
import Alamofire // 1 | |
class MockDataRequest: DataRequestProtocol { // 2 | |
// 3 | |
static var statusCode: Int = 200 | |
static var data: Data? | |
var dataResponse = AFDataResponse<Any>( | |
request: nil, | |
response: HTTPURLResponse(url: URL(string: "test.ykpoh.com")!, statusCode: MockDataRequest.statusCode, httpVersion: "1.1", headerFields: nil), | |
data: MockDataRequest.data, | |
metrics: nil, | |
serializationDuration: TimeInterval(), | |
result: Result.success(true) | |
) | |
func response(completionHandler: @escaping (AFDataResponse<Any>) -> Void) -> Self { | |
completionHandler(dataResponse) | |
return self | |
} | |
func responseJSON(completionHandler: @escaping (AFDataResponse<Any>) -> Void) -> Self { | |
return response(completionHandler: completionHandler) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment