Skip to content

Commit

Permalink
Merge pull request #43 from jeantimex/simplify-heightForRowAt
Browse files Browse the repository at this point in the history
Simplify heightForRowAt.
  • Loading branch information
jeantimex authored Aug 3, 2017
2 parents 360c9af + f46fc5e commit 2f12665
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CollapsibleTableSectionViewController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "CollapsibleTableSectionViewController"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "Swift 3.0 library to support collapsible sections in a table view."

# This description is used to generate tags and improve search results.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ extension CollapsibleTableSectionViewController: UITableViewDataSource, UITableV
}

public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let section = (indexPath as NSIndexPath).section
return isSectionCollapsed(section) ? 0 : UITableViewAutomaticDimension
return UITableViewAutomaticDimension
}

public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,29 +150,7 @@ class CollapsibleTableSectionViewControllerTests: XCTestCase {
// Test heightForRowAt
//

func testReturnsZeroWhenSectionIsCollapsed() {
class MockCollapsibleTableSectionViewController: CollapsibleTableSectionViewController {
override public func isSectionCollapsed(_ section: Int) -> Bool {
return true
}
}

viewController = MockCollapsibleTableSectionViewController()

let heightForRowAt = viewController.tableView(tableView, heightForRowAt: IndexPath(row: 0, section: 0))

XCTAssertEqual(heightForRowAt, 0)
}

func testReturnsUITableViewAutomaticDimension() {
class MockCollapsibleTableSectionViewController: CollapsibleTableSectionViewController {
override public func isSectionCollapsed(_ section: Int) -> Bool {
return false
}
}

viewController = MockCollapsibleTableSectionViewController()

let heightForRowAt = viewController.tableView(tableView, heightForRowAt: IndexPath(row: 0, section: 0))

XCTAssertEqual(heightForRowAt, UITableViewAutomaticDimension)
Expand Down

0 comments on commit 2f12665

Please sign in to comment.