Skip to content

Commit

Permalink
- Add context data values display to /Examples/Conversations/Swift re…
Browse files Browse the repository at this point in the history
…view cell

- Fix unit tests using OHHTTPStubs
  • Loading branch information
Tim Kelly committed May 5, 2017
1 parent c4ff907 commit 637fe43
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,26 @@ class MyReviewTableViewCell: BVReviewTableViewCell {
// let's see if this author has any badges
for badge : BVBadge in (review?.badges)! {

badgesString += " \(badge.identifier!)) "
badgesString += " \(badge.identifier!) "

}

badgesString += "]"

titleString = titleString?.appending("\nBy \(review!.authorId ?? "no author") on \(dateString)\(badgesString)")
titleString = titleString?.appending("\nBy \(review!.userNickname ?? "no author") on \(dateString)\(badgesString)")

// Add any context data values, if present. E.g. Age, Gender, other....
for contextDataValue in (review?.contextDataValues)! {
titleString?.append("\n\(contextDataValue.dimensionLabel!): \(contextDataValue.valueLabel!)")
}

reviewTitle.text = titleString

// Create a review body some example of data we can pull in.
var reviewString = review?.reviewText

reviewString?.append("\n")

reviewString?.append("\nIs Recommended? \(review!.isRecommended)")
reviewString?.append("\nIs Syndicated? \(review!.isSyndicated)")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ProfileDisplayTests: XCTestCase {
let configDict = ["clientId": "conciergeapidocumentation",
"apiKeyConversations": "caB45h2jBqXFw1OE043qoMBD1gJC8EwFNCjktzgwncXY4"];
BVSDKManager.configure(withConfiguration: configDict, configType: .staging)
BVSDKManager.shared().setLogLevel(.verbose)
BVSDKManager.shared().setLogLevel(.error)
}

override func tearDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ class ReviewDisplayTests: XCTestCase {
let configDict = ["clientId": "apitestcustomer",
"apiKeyConversations": "kuy3zj9pr3n7i0wxajrzj04xo"];
BVSDKManager.configure(withConfiguration: configDict, configType: .staging)
BVSDKManager.shared().setLogLevel(BVLogLevel.verbose)
BVSDKManager.shared().setLogLevel(BVLogLevel.error)
}

override func tearDown() {
super.tearDown()
OHHTTPStubs.removeAllStubs()

}

func testReviewDisplay() {

Expand Down Expand Up @@ -93,7 +98,6 @@ class ReviewDisplayTests: XCTestCase {


stub(condition: isHost("stg.api.bazaarvoice.com")) { _ in
// Stub it with our "storeItemWithStatsAndReviews.json" stub file (which is in same bundle as self)
let stubPath = OHPathForFile("testSyndicationSource.json", type(of: self))
return fixture(filePath: stubPath!, headers: ["Content-Type" as NSObject:"application/json" as AnyObject])
}
Expand All @@ -119,6 +123,7 @@ class ReviewDisplayTests: XCTestCase {
}) { (error) in

XCTFail("review display request error: \(error)")
expectation.fulfill()

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ConversationsStoresDisplayTests: XCTestCase {

override func tearDown() {
super.tearDown()
OHHTTPStubs.removeAllStubs()
}

// This tests fetching reviews from a single store, but store id, given a limit and offset.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ReviewSubmissionTests: XCTestCase {
let configDict = ["clientId": "apitestcustomer",
"apiKeyConversations": "2cpdrhohmgmwfz8vqyo48f52g"];
BVSDKManager.configure(withConfiguration: configDict, configType: .staging)
BVSDKManager.shared().setLogLevel(.verbose)
BVSDKManager.shared().setLogLevel(.error)
}

func testSubmitReviewWithPhoto() {
Expand All @@ -26,7 +26,7 @@ class ReviewSubmissionTests: XCTestCase {

let review = self.fillOutReview(.submit)
review.submit({ (reviewSubmission) in
//XCTAssertTrue(reviewSubmission.formFields?.keys.count == 0)
XCTAssertTrue(reviewSubmission.formFields?.keys.count == 0)
expectation.fulfill()
}, failure: { (errors) in
XCTFail()
Expand All @@ -43,7 +43,7 @@ class ReviewSubmissionTests: XCTestCase {
let review = self.fillOutReview(.preview)
review.submit({ (reviewSubmission) in
// When run in Preview mode, we get the formFields that can be used for submission.
//XCTAssertTrue(reviewSubmission.formFields?.keys.count == 50)
XCTAssertTrue(reviewSubmission.formFields?.keys.count == 50)
expectation.fulfill()
}, failure: { (errors) in
XCTFail()
Expand Down Expand Up @@ -82,31 +82,31 @@ class ReviewSubmissionTests: XCTestCase {
review.addRatingQuestion("HowDoes", value: 4)
review.addRatingQuestion("Fit", value: 3)

// if let image = PhotoUploadTests.createImage() {
// review.addPhoto(image, withPhotoCaption: "Yo dawg")
// }
if let image = PhotoUploadTests.createImage() {
review.addPhoto(image, withPhotoCaption: "Yo dawg")
}

return review
}


// func testSubmitReviewFailure() {
// let expectation = self.expectation(description: "testSubmitReviewFailure")
//
// let review = BVReviewSubmission(reviewTitle: "", reviewText: "", rating: 123, productId: "1000001")
// review.userNickname = "cgil"
// review.userId = "craiggiddl"
// review.action = .submit
//
// review.submit({ (reviewSubmission) in
// XCTFail()
// expectation.fulfill()
// }, failure: { (errors) in
// errors.forEach { print("Expected Failure Item: \($0)") }
// XCTAssertEqual(errors.count, 5)
// expectation.fulfill()
// })
// waitForExpectations(timeout: 10, handler: nil)
// }
func testSubmitReviewFailure() {
let expectation = self.expectation(description: "testSubmitReviewFailure")

let review = BVReviewSubmission(reviewTitle: "", reviewText: "", rating: 123, productId: "1000001")
review.userNickname = "cgil"
review.userId = "craiggiddl"
review.action = .submit

review.submit({ (reviewSubmission) in
XCTFail()
expectation.fulfill()
}, failure: { (errors) in
errors.forEach { print("Expected Failure Item: \($0)") }
XCTAssertEqual(errors.count, 5)
expectation.fulfill()
})
waitForExpectations(timeout: 10, handler: nil)
}

}

0 comments on commit 637fe43

Please sign in to comment.