This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - View | |
final class GatherMockView: GatherViewProtocol { | |
var presenter: GatherPresenterProtocol! | |
var loadingView = LoadingView() | |
private(set) var title: String? | |
private(set) var timerViewIsHidden = false | |
private(set) var selectionDictionary: [Int: Int] = [:] | |
private(set) var timerLabelText: String? | |
private(set) var actionButtonTitle: String? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Actions | |
func testRequestToEndGather_whenPresenterIsAllocated_viewDisplaysConfirmationAlert() { | |
// given | |
let mockView = GatherMockView() | |
let mockInteractor = GatherInteractor(gather: GatherModel(players: [], gatherUUID: UUID())) | |
let sut = GatherPresenter(view: mockView, interactor: mockInteractor) | |
// when | |
sut.requestToEndGather() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Stepper Handler | |
func testUpdateValue_whenTeamIsA_viewSetsTeamALabelTextWithNewValue() { | |
// given | |
let mockValue = 15.0 | |
let mockView = GatherMockView() | |
let mockInteractor = GatherInteractor(gather: GatherModel(players: [], gatherUUID: UUID())) | |
let sut = GatherPresenter(view: mockView, interactor: mockInteractor) | |
// when | |
sut.updateValue(for: .teamA, with: mockValue) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Table Data Source | |
func testNumberOfSections_whenPresenterIsAllocated_equalsTeamSectionsCount() { | |
// given | |
let mockInteractor = GatherInteractor(gather: GatherModel(players: [], gatherUUID: UUID())) | |
let sut = GatherPresenter(interactor: mockInteractor) | |
// when | |
let numberOfSections = sut.numberOfSections | |
// then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class GatherPresenterTests: XCTestCase { | |
// MARK: - GatherPresenterViewConfiguration | |
func testViewDidLoad_whenPresenterIsAllocated_configuresView() { | |
// given | |
let mockView = GatherMockView() | |
let mockInteractor = GatherInteractor(gather: GatherModel(players: [], gatherUUID: UUID())) | |
let sut = GatherPresenter(view: mockView, interactor: mockInteractor) | |
// when |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - UITableViewCell | |
extension UITableViewCell: GatherTableViewCellProtocol {} | |
// MARK: - Loadable | |
extension GatherViewController: Loadable {} | |
// MARK: - Error Handler | |
extension GatherViewController: ErrorHandler {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - UITableViewDelegate | UITableViewDataSource | |
extension GatherViewController: UITableViewDelegate, UITableViewDataSource { | |
func numberOfSections(in tableView: UITableView) -> Int { | |
presenter.numberOfSections | |
} | |
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | |
presenter.titleForHeaderInSection(section) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Confirmation | |
extension GatherViewController: GatherViewConfirmable { | |
func displayConfirmationAlert() { | |
let alertController = UIAlertController(title: "End Gather", message: "Are you sure you want to end the gather?", preferredStyle: .alert) | |
let confirmAction = UIAlertAction(title: "Yes", style: .default) { [weak self] _ in | |
self?.presenter.endGather() | |
} | |
alertController.addAction(confirmAction) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Reload | |
extension GatherViewController: GatherViewReloadable { | |
func reloadData() { | |
timePickerView.reloadAllComponents() | |
playerTableView.reloadData() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Configuration | |
extension GatherViewController: GatherViewConfigurable { | |
var scoreDescription: String { | |
scoreLabelView.scoreDescription | |
} | |
var winnerTeamDescription: String { | |
scoreLabelView.winnerTeamDescription | |
} |