Skip to content

Commit

Permalink
clean cellViewModel + coordinator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesquires committed Oct 3, 2024
1 parent 56c3868 commit 87813f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Sources/CellViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,8 @@ public struct AnyCellViewModel: CellViewModel {
precondition(cell is T.CellType, "Cell must be of type \(T.CellType.self). Found \(cell.self)")
viewModel.configure(cell: cell as! T.CellType)
}
self._didSelect = { coordinator in
viewModel.didSelect(with: coordinator)
}
self._didDeselect = viewModel.didDeselect
self._didSelect = viewModel.didSelect(with:)
self._didDeselect = viewModel.didDeselect(with:)
self._willDisplay = viewModel.willDisplay
self._didEndDisplaying = viewModel.didEndDisplaying
self._didHighlight = viewModel.didHighlight
Expand Down
4 changes: 4 additions & 0 deletions Tests/TestCellEventCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ final class TestCellEventCoordinator: UnitTestCase, @unchecked Sendable {
let indexPath = IndexPath(item: 0, section: 0)
driver.collectionView(self.collectionView, didSelectItemAt: indexPath)

XCTAssertEqual(coordinator.selectedCell as! FakeCellViewModel, cell)

self.waitForExpectations()

self.keepDriverAlive(driver)
Expand All @@ -70,6 +72,8 @@ final class TestCellEventCoordinator: UnitTestCase, @unchecked Sendable {
let indexPath = IndexPath(item: 0, section: 0)
driver.collectionView(self.collectionView, didDeselectItemAt: indexPath)

XCTAssertEqual(coordinator.deselectedCell as! FakeCellViewModel, cell)

self.waitForExpectations()

self.keepDriverAlive(driver)
Expand Down

0 comments on commit 87813f5

Please sign in to comment.