-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TableView and CollectionView protocol #139
Conversation
@jessesquires current state is that there's only
The down side is the |
@@ -35,7 +35,7 @@ open class TableViewDriver: NSObject { | |||
} | |||
|
|||
/// The table view to which the `TableViewModel` is rendered. | |||
public let tableView: UITableView | |||
let tableView: TableView |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed okay to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tried it internally, but I think in most cases, you'll have another pointer to this view anyway.
@@ -72,6 +72,8 @@ open class TableViewDriver: NSObject { | |||
|
|||
private let _automaticDiffingEnabled: Bool | |||
|
|||
private let _registerViews: (TableViewModel) -> Void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed to avoid associatedtype
issues with CellContainerViewProtocol
.
@@ -16,7 +16,7 @@ | |||
|
|||
import UIKit | |||
|
|||
extension UITableView { | |||
extension TableView where Self: CellContainerViewProtocol, Self.CellType: UITableViewCell { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protocol extension with generic constraints!
5d15048
to
20938c4
Compare
return | ||
} | ||
XCTAssertEqual(onScreenHeader.label, "title_header+A") | ||
XCTAssertNil(self._tableView.headerView(forSection: indexKey.section)) | ||
XCTAssertNotNil(self._tableView.headerView(forSection: indexKey.section)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this flipped? seems like it's correct now. @jessesquires did I mess this up? or does this seem right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. I didn't write any of these tests and they're all mostly really bad 😄 😅
@@ -213,7 +217,8 @@ final class TableViewDriverTests: XCTestCase { | |||
let tableView = TestTableView() | |||
self.setupWithTableView(tableView) | |||
|
|||
XCTAssertEqual(tableView.callsToRegisterClass.count, 2) | |||
// 1 header + 1 footer + 6 cells | |||
XCTAssertEqual(tableView.callsToRegisterClass.count, 8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improved count, now that we're exercising the registerViews(for:)
functionality in the constrained protocol extension
Hm... I don't think I fully understand the goals here and what we're gaining by doing this. What's wrong with subclassing
I'm not sure I'm following here. We don't need to test RE: this comment #136 (comment) FWIW, I generally don't like the introduction of the We should probably discuss in person 😄 |
I tried dropping in a
That's certainly one approach. It does expose the tests to flaking due to bugs in UIKit though, as well as further extends the reach to already very integration-y unit tests.
Hm I actually thought a protocol might be the layer of indirection we needed to have the unified API. We could evolve this into a |
Ah yes, that's correct. We've started laying that groundwork with |
I can do that, but then I'd have to make |
Changes in this pull request
This adds
TableView
andCollectionView
protocols, so that the concreteUITableView
andUICollectionView
can be used less often in tests. This fixes the testing issues that surfaced in #136.Checklist
CHANGELOG.md
for any breaking changes, enhancements, or bug fixes.In-Progress TODOs
CollectionView