Skip to content

Commit

Permalink
Update: Type safe UIKit tests to match dequeue method cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
allbto committed May 2, 2016
1 parent 7586356 commit 8cf6f62
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Swiftility/SwiftilityTests/TypeSafeUIKitTestsCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TestView: UIView {}

class TestCell: UITableViewCell, FromNib
{
static var nib: NibConvertible {
static var ownNib: NibConvertible {
return NibContainer(String(self), bundle: NSBundle(forClass: StoryboardTests.self))
}
}
Expand All @@ -68,7 +68,7 @@ class TestNonExistingCell: UITableViewCell, FromNib {}

class TestCollectionViewCell: UICollectionViewCell, FromNib
{
static var nib: NibConvertible {
static var ownNib: NibConvertible {
return NibContainer(String(self), bundle: NSBundle(forClass: StoryboardTests.self))
}
}
Expand All @@ -77,7 +77,7 @@ class TestNonExistingCollectionViewCell: UICollectionViewCell, FromNib {}

class TestCollectionViewView: UICollectionReusableView, FromNib
{
static var nib: NibConvertible {
static var ownNib: NibConvertible {
return NibContainer(String(self), bundle: NSBundle(forClass: StoryboardTests.self))
}
}
Expand Down
5 changes: 4 additions & 1 deletion Swiftility/SwiftilityTests/UICollectionViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ class UICollectionViewTests: XCTestCase

expect(collectionView!.registerCell(TestCollectionViewCell)).toNot(raiseException())

expect(collectionView!.dequeueReusableCell(TestCollectionViewCell.self, forIndexPath: NSIndexPath(forRow: 0, inSection: 0))).to(beTruthy())
let cell: TestCollectionViewCell = collectionView!.dequeueReusableCell(forIndexPath: NSIndexPath(forRow: 0, inSection: 0))

expect(cell).to(beTruthy())
}

// TODO: Add test for reusableSupplementaryView
// func testDequeueView()
// {
// let collectionView = self.collectionVC.collectionView
Expand Down
8 changes: 6 additions & 2 deletions Swiftility/SwiftilityTests/UITableViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class UITableViewTests: XCTestCase
// tableView.dequeueReusableCell(TestNonExistingCell)
// }

expect(tableView.dequeueReusableCell(TestCell)).to(beTruthy())
let cell: TestCell = tableView.dequeueReusableCell()

expect(cell).to(beTruthy())
}

func testDequeueCellOnViewController()
Expand All @@ -45,6 +47,8 @@ class UITableViewTests: XCTestCase
// tableVC.tableView.dequeueReusableCell(TestNonExistingCell)
// }

expect(tableVC.tableView.dequeueReusableCell(TestCell)).to(beTruthy())
let cell: TestCell = tableVC.tableView.dequeueReusableCell()

expect(cell).to(beTruthy())
}
}
8 changes: 4 additions & 4 deletions Swiftility/SwiftilityTests/UIViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class UIViewControllerTests: XCTestCase

func testNibConvertible()
{
expect(TestVC.nib.nibName) == "TestVC"
expect(TestVC.nib.bundle).to(beNil())
expect(TestVC.ownNib.nibName) == "TestVC"
expect(TestVC.ownNib.bundle).to(beNil())
}

func testViewNibConvertible()
{
expect(TestView.nib.nibName) == "TestView"
expect(TestView.nib.bundle).to(beNil())
expect(TestView.ownNib.nibName) == "TestView"
expect(TestView.ownNib.bundle).to(beNil())
}
}

0 comments on commit 8cf6f62

Please sign in to comment.