Skip to content

Commit

Permalink
Use optional instead of forced unwrapping in unit tests
Browse files Browse the repository at this point in the history
per feedback on #76
  • Loading branch information
cdzombak committed Oct 14, 2015
1 parent c3e38ab commit a30446e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ class NYTPhotosOverlayViewTests: XCTestCase {
let overlayView = NYTPhotosOverlayView()
let leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: nil, action: nil)
overlayView.leftBarButtonItem = leftBarButtonItem
XCTAssert(leftBarButtonItem == overlayView.navigationBar.items!.first?.leftBarButtonItem)
XCTAssert(leftBarButtonItem == overlayView.navigationBar.items?.first?.leftBarButtonItem)
}

func testRightBarButtonItemSetterAffectsNavigationBar() {
let overlayView = NYTPhotosOverlayView()
let rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: nil, action: nil)
overlayView.rightBarButtonItem = rightBarButtonItem
XCTAssert(rightBarButtonItem == overlayView.navigationBar.items!.first?.rightBarButtonItem)
XCTAssert(rightBarButtonItem == overlayView.navigationBar.items?.first?.rightBarButtonItem)
}

func testTitleSetterAffectsNavigationBar() {
let overlayView = NYTPhotosOverlayView()
let title = "title"
overlayView.title = title
XCTAssert(title == overlayView.navigationBar.items!.first!.title)
XCTAssert(title == overlayView.navigationBar.items?.first?.title)
}

func testTitleTextAttributesSetterAffectsNavigationBar() {
let overlayView = NYTPhotosOverlayView()
let titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orangeColor()]
overlayView.titleTextAttributes = titleTextAttributes
XCTAssertEqual(titleTextAttributes, overlayView.navigationBar.titleTextAttributes as! [String: UIColor])
XCTAssertEqual(titleTextAttributes, overlayView.navigationBar.titleTextAttributes as? [String: UIColor])
}
}

0 comments on commit a30446e

Please sign in to comment.