Skip to content

Commit

Permalink
Merge pull request #963 from DeluxeAlonso/feature/code-cleanup
Browse files Browse the repository at this point in the history
Feature/code cleanup
  • Loading branch information
DeluxeAlonso authored Aug 27, 2024
2 parents d03f627 + 2a2593d commit 2d8ab39
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protocol MovieDetailViewModelProtocol {

var screenTitle: String { get }
var shareTitle: String { get }
var cancelTitle: String { get }

var startLoading: AnyBehaviorBindable<Bool> { get }
var showGenreName: AnyBehaviorBindable<String> { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ final class MovieDetailViewController: UIViewController, Storyboarded, Transitio
let availableActions = actionModels.map { actionModel in
UIAlertAction(title: actionModel.title, style: .default) { _ in actionModel.action() }
}
let cancelAction = UIAlertAction(title: LocalizedStrings.cancel(), style: .cancel) { _ in
let cancelAction = UIAlertAction(title: viewModel?.cancelTitle, style: .cancel) { _ in
self.dismiss(animated: true)
}
let actions = [cancelAction] + availableActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ final class MovieDetailViewModel: MovieDetailViewModelProtocol {
String(format: LocalizedStrings.movieDetailShareText(), title)
}

var cancelTitle: String {
LocalizedStrings.cancel()
}

// MARK: - Initializers

init(_ movie: MovieProtocol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ final class MovieDetailViewModelTests: XCTestCase {
XCTAssertEqual(screenTitle, String(format: LocalizedStrings.movieDetailShareText(), titleToTest))
}

func testCancelTitle() {
// Arrange
let viewModelToTest = createSUT(with: MockMovieProtocol())
// Act
let cancelTitle = viewModelToTest.cancelTitle
// Assert
XCTAssertEqual(cancelTitle, "Cancel")
}

func testSaveVisitedMovie() {
// Arrange
let viewModelToTest = createSUT(with: 1, title: "Title")
Expand Down

0 comments on commit 2d8ab39

Please sign in to comment.