From 5eb5470c72e2ef3cf28721649ac653ba74fbb4aa Mon Sep 17 00:00:00 2001 From: DeluxeAlonso Date: Sun, 25 Aug 2024 15:53:56 -0500 Subject: [PATCH 1/5] Updates CustomListDetailViewModelProtocol --- .../Account/CustomListDetail/CustomListDetailProtocols.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift index b9775165..96f1a52b 100644 --- a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift +++ b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift @@ -14,6 +14,8 @@ protocol CustomListDetailViewModelProtocol { var viewState: AnyBehaviorBindable { get } var movieCells: [MovieListCellViewModel] { get } + var emptyMovieResults: String? { get } + func buildHeaderViewModel() -> CustomListDetailHeaderViewModelProtocol func buildSectionViewModel() -> CustomListDetailSectionViewModel From 39dd6cb753aa9f200b00f5b34e940dc7e0238fab Mon Sep 17 00:00:00 2001 From: DeluxeAlonso Date: Sun, 25 Aug 2024 21:42:23 -0500 Subject: [PATCH 2/5] Updates CustomListDetailViewModel --- .../Account/CustomListDetail/CustomListDetailProtocols.swift | 2 +- .../Account/CustomListDetail/CustomListDetailViewModel.swift | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift index 96f1a52b..a561e350 100644 --- a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift +++ b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift @@ -14,7 +14,7 @@ protocol CustomListDetailViewModelProtocol { var viewState: AnyBehaviorBindable { get } var movieCells: [MovieListCellViewModel] { get } - var emptyMovieResults: String? { get } + var emptyMovieResultsTitle: String? { get } func buildHeaderViewModel() -> CustomListDetailHeaderViewModelProtocol func buildSectionViewModel() -> CustomListDetailSectionViewModel diff --git a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewModel.swift b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewModel.swift index e6508a72..ddf93c56 100644 --- a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewModel.swift +++ b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewModel.swift @@ -21,6 +21,10 @@ final class CustomListDetailViewModel: CustomListDetailViewModelProtocol { // MARK: - Computed properties + var emptyMovieResultsTitle: String? { + LocalizedStrings.emptyMovieResults() + } + private var movies: [MovieProtocol] { viewState.value.currentMovies } From 9569ca48e286c97d03965ec700cb7ff99b51bce0 Mon Sep 17 00:00:00 2001 From: DeluxeAlonso Date: Sun, 25 Aug 2024 21:43:25 -0500 Subject: [PATCH 3/5] Updates CustomListDetailViewController --- .../Account/CustomListDetail/CustomListDetailProtocols.swift | 2 +- .../CustomListDetail/CustomListDetailViewController.swift | 3 ++- .../Account/CustomListDetail/CustomListDetailViewModel.swift | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift index a561e350..5f3bdb5c 100644 --- a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift +++ b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailProtocols.swift @@ -14,7 +14,7 @@ protocol CustomListDetailViewModelProtocol { var viewState: AnyBehaviorBindable { get } var movieCells: [MovieListCellViewModel] { get } - var emptyMovieResultsTitle: String? { get } + var emptyMovieResultsTitle: String { get } func buildHeaderViewModel() -> CustomListDetailHeaderViewModelProtocol func buildSectionViewModel() -> CustomListDetailSectionViewModel diff --git a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewController.swift b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewController.swift index 6918bc0c..1a45247c 100644 --- a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewController.swift +++ b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewController.swift @@ -109,7 +109,8 @@ final class CustomListDetailViewController: UIViewController, Storyboarded { 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) case .populated: tableView.tableFooterView = UIView() case .loading: diff --git a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewModel.swift b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewModel.swift index ddf93c56..c1132422 100644 --- a/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewModel.swift +++ b/UpcomingMovies/Scenes/Account/CustomListDetail/CustomListDetailViewModel.swift @@ -21,7 +21,7 @@ final class CustomListDetailViewModel: CustomListDetailViewModelProtocol { // MARK: - Computed properties - var emptyMovieResultsTitle: String? { + var emptyMovieResultsTitle: String { LocalizedStrings.emptyMovieResults() } From 36d8d53d3f2ad23971b2787531e45e0b45cb185f Mon Sep 17 00:00:00 2001 From: DeluxeAlonso Date: Mon, 26 Aug 2024 00:15:36 -0500 Subject: [PATCH 4/5] Updates MockCustomListDetailViewModel --- .../CustomListDetailViewModelTests.swift | 9 +++++++++ .../Helpers/Mocks/CustomListDetailMockFactory.swift | 2 ++ 2 files changed, 11 insertions(+) diff --git a/UpcomingMoviesTests/Account/CustomListDetail/CustomListDetailViewModelTests.swift b/UpcomingMoviesTests/Account/CustomListDetail/CustomListDetailViewModelTests.swift index 8b6548d6..d3cb036d 100644 --- a/UpcomingMoviesTests/Account/CustomListDetail/CustomListDetailViewModelTests.swift +++ b/UpcomingMoviesTests/Account/CustomListDetail/CustomListDetailViewModelTests.swift @@ -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, "") + } + private func createSUT(list: ListProtocol) -> CustomListDetailViewModel { CustomListDetailViewModel(list, interactor: interactor) } diff --git a/UpcomingMoviesTests/Helpers/Mocks/CustomListDetailMockFactory.swift b/UpcomingMoviesTests/Helpers/Mocks/CustomListDetailMockFactory.swift index c6cd63c0..2603fea2 100644 --- a/UpcomingMoviesTests/Helpers/Mocks/CustomListDetailMockFactory.swift +++ b/UpcomingMoviesTests/Helpers/Mocks/CustomListDetailMockFactory.swift @@ -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 { From a9377cf2b301a31ba60f1670510d2daa0ef868ac Mon Sep 17 00:00:00 2001 From: DeluxeAlonso Date: Mon, 26 Aug 2024 00:27:39 -0500 Subject: [PATCH 5/5] Updates CustomListDetailViewModelTests --- .../CustomListDetail/CustomListDetailViewModelTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UpcomingMoviesTests/Account/CustomListDetail/CustomListDetailViewModelTests.swift b/UpcomingMoviesTests/Account/CustomListDetail/CustomListDetailViewModelTests.swift index d3cb036d..f8dff37f 100644 --- a/UpcomingMoviesTests/Account/CustomListDetail/CustomListDetailViewModelTests.swift +++ b/UpcomingMoviesTests/Account/CustomListDetail/CustomListDetailViewModelTests.swift @@ -39,7 +39,7 @@ final class CustomListDetailViewModelTests: XCTestCase { // Act let emptyMovieResultsTitle = viewModel.emptyMovieResultsTitle // Assert - XCTAssertEqual(emptyMovieResultsTitle, "") + XCTAssertEqual(emptyMovieResultsTitle, "There are no movies to show right now.") } private func createSUT(list: ListProtocol) -> CustomListDetailViewModel {