|
@@ -25,7 +25,7 @@ import Alamofire
|
|
|
import XCTest
|
|
import XCTest
|
|
|
|
|
|
|
|
class AlamofireJSONResponseTestCase: XCTestCase {
|
|
class AlamofireJSONResponseTestCase: XCTestCase {
|
|
|
- func testJSONResponse() {
|
|
|
|
|
|
|
+ func testGETRequestJSONResponse() {
|
|
|
let URL = "http://httpbin.org/get"
|
|
let URL = "http://httpbin.org/get"
|
|
|
let expectation = expectationWithDescription("\(URL)")
|
|
let expectation = expectationWithDescription("\(URL)")
|
|
|
|
|
|
|
@@ -44,4 +44,24 @@ class AlamofireJSONResponseTestCase: XCTestCase {
|
|
|
XCTAssertNil(error, "\(error)")
|
|
XCTAssertNil(error, "\(error)")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ func testPOSTRequestJSONResponse() {
|
|
|
|
|
+ let URL = "http://httpbin.org/post"
|
|
|
|
|
+ let expectation = expectationWithDescription("\(URL)")
|
|
|
|
|
+
|
|
|
|
|
+ Alamofire.request(.POST, URL, parameters: ["foo": "bar"])
|
|
|
|
|
+ .responseJSON { (request, response, JSON, error) in
|
|
|
|
|
+ expectation.fulfill()
|
|
|
|
|
+ XCTAssertNotNil(request, "request should not be nil")
|
|
|
|
|
+ XCTAssertNotNil(response, "response should not be nil")
|
|
|
|
|
+ XCTAssertNotNil(JSON, "JSON should not be nil")
|
|
|
|
|
+ XCTAssertNil(error, "error should be nil")
|
|
|
|
|
+
|
|
|
|
|
+ XCTAssertEqual(JSON!["form"] as NSObject, ["foo": "bar"], "args should be equal")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ waitForExpectationsWithTimeout(10) { (error) in
|
|
|
|
|
+ XCTAssertNil(error, "\(error)")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|