Skip to content
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

Feature/code cleanup #962

Merged
merged 6 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ protocol CustomListDetailViewModelProtocol {
var viewState: AnyBehaviorBindable<CustomListDetailViewState> { get }
var movieCells: [MovieListCellViewModel] { get }

var emptyMovieResultsTitle: String { get }

func buildHeaderViewModel() -> CustomListDetailHeaderViewModelProtocol
func buildSectionViewModel() -> CustomListDetailSectionViewModel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
private func configureView(with state: CustomListDetailViewState) {
switch state {
case .empty:
tableView.tableFooterView = FooterView(message: LocalizedStrings.emptyMovieResults())
guard let viewModel else { return }
tableView.tableFooterView = FooterView(message: viewModel.emptyMovieResultsTitle)

Check warning on line 113 in UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewController.swift

View check run for this annotation

Codecov / codecov/patch

UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewController.swift#L112-L113

Added lines #L112 - L113 were not covered by tests
case .populated:
tableView.tableFooterView = UIView()
case .loading:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ final class CustomListDetailViewModel: CustomListDetailViewModelProtocol {

// MARK: - Computed properties

var emptyMovieResultsTitle: String {
LocalizedStrings.emptyMovieResults()
}

private var movies: [MovieProtocol] {
viewState.value.currentMovies
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ final class CustomListDetailViewModelTests: XCTestCase {
XCTAssertEqual(listName, nameToTest)
}

func testEmptyMovieResultsTitle() {
// Arrange
let viewModel = createSUT(list: MockListProtocol())
// Act
let emptyMovieResultsTitle = viewModel.emptyMovieResultsTitle
// Assert
XCTAssertEqual(emptyMovieResultsTitle, "There are no movies to show right now.")
}

private func createSUT(list: ListProtocol) -> CustomListDetailViewModel {
CustomListDetailViewModel(list, interactor: interactor)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ final class MockCustomListDetailViewModel: CustomListDetailViewModelProtocol {

var movieCells: [MovieListCellViewModel] = []

var emptyMovieResultsTitle: String = ""

var buildHeaderViewModelCallCount = 0
var buildHeaderViewModelResult = CustomListDetailHeaderViewModel(list: MockListProtocol())
func buildHeaderViewModel() -> CustomListDetailHeaderViewModelProtocol {
Expand Down
Loading