Skip to content

Commit

Permalink
Fix broken testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
wongzigii committed Feb 25, 2017
1 parent f936cbb commit 746a638
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Source/Alamofire-SwiftyJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extension DataRequest {
-> DataResponseSerializer<JSON>
{
return DataResponseSerializer { _, response, data, error in
return Request.serializeResponseSwiftyJSON(options: options, response: response, data: data, error: error)
return Request.serializeResponseSwiftyJSON(options: options, response: response, data: data, error: error)
}
}

Expand Down
26 changes: 12 additions & 14 deletions Tests/Alamofire_SwiftyJSONTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,26 @@
// Copyright (c) 2014年 SwiftJSON. All rights reserved.
//

import UIKit
import XCTest
import Alamofire
import SwiftyJSON
import AlamofireSwiftyJSON

class Alamofire_SwiftyJSONTests: XCTestCase {

func testJSONResponse() {
func testGETRequestJSONResponse() {
let URL = "http://httpbin.org/get"
let expectation = expectationWithDescription("\(URL)")

Alamofire.request(.GET, URL, parameters: ["foo": "bar"]).responseSwiftyJSON({(request, response, responseJSON, error) in
expectation.fulfill()
XCTAssertNotNil(request, "request should not be nil")
XCTAssertNotNil(response, "response should not be nil")
XCTAssertTrue(error == nil, "result error should be nil")
XCTAssertEqual(responseJSON["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal")
})
waitForExpectationsWithTimeout(10) { (error) in
XCTAssertNil(error, "\(error)")
let parameters: Parameters = ["foo": "bar"]
let expect = expectation(description: "responseSwiftyJSON method should work")
Alamofire.request(URL, method: .get, parameters: parameters, encoding: URLEncoding.default)
.validate()
.responseSwiftyJSON { response in
XCTAssertNotNil(response.request, "request should not be nil")
XCTAssertNotNil(response.response, "response should not be nil")
XCTAssertNil(response.error, "result error should be nil")
XCTAssertEqual(response.value?["args"], SwiftyJSON.JSON(["foo": "bar"] as NSDictionary), "args should be equal")
expect.fulfill()
}
waitForExpectations(timeout: 10.0, handler: nil)
}

}

0 comments on commit 746a638

Please sign in to comment.