Skip to content

Instantly share code, notes, and snippets.

View radude89's full-sized avatar
🏖️
Swifting

Radu Dan radude89

🏖️
Swifting
View GitHub Profile
@radude89
radude89 / viper-fg-47.swift
Created July 15, 2021 03:30
viper-fg-47.swift
// 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?
@radude89
radude89 / viper-fg-46.swift
Created July 15, 2021 03:29
viper-fg-46.swift
// 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()
@radude89
radude89 / viper-fg-45.swift
Created July 15, 2021 03:29
viper-fg-45.swift
// 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)
@radude89
radude89 / viper-fg-44.swift
Created July 15, 2021 03:28
viper-fg-44.swift
// 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
@radude89
radude89 / viper-fg-43.swift
Created July 15, 2021 03:28
viper-fg-43.swift
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
@radude89
radude89 / viper-fg-42.swift
Created July 15, 2021 03:28
viper-fg-42.swift
// MARK: - UITableViewCell
extension UITableViewCell: GatherTableViewCellProtocol {}
// MARK: - Loadable
extension GatherViewController: Loadable {}
// MARK: - Error Handler
extension GatherViewController: ErrorHandler {}
@radude89
radude89 / viper-fg-41.swift
Created July 15, 2021 03:27
viper-fg-41.swift
// 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)
}
@radude89
radude89 / viper-fg-40.swift
Created July 15, 2021 03:27
viper-fg-40.swift
// 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)
@radude89
radude89 / viper-fg-39.swift
Created July 15, 2021 03:27
viper-fg-39.swift
// MARK: - Reload
extension GatherViewController: GatherViewReloadable {
func reloadData() {
timePickerView.reloadAllComponents()
playerTableView.reloadData()
}
}
@radude89
radude89 / viper-fg-38.swift
Created July 15, 2021 03:27
viper-fg-38.swift
// MARK: - Configuration
extension GatherViewController: GatherViewConfigurable {
var scoreDescription: String {
scoreLabelView.scoreDescription
}
var winnerTeamDescription: String {
scoreLabelView.winnerTeamDescription
}