//
//  SettingsAlertSingleTypePresenterTests.swift
//  xDrip
//
//  Created by Artem Kalmykov on 09.04.2020.
//  Copyright (c) 2020 Faifly. All rights reserved.
//
//  This file was generated by the Clean Swift Xcode Templates so
//  you can apply clean architecture to your iOS and Mac projects,
//  see http://clean-swift.com
//

@testable import xDrip
import XCTest

// swiftlint:disable implicitly_unwrapped_optional

final class SettingsAlertSingleTypePresenterTests: XCTestCase {
    // MARK: Subject under test
    
    var sut: SettingsAlertSingleTypePresenter!
    
    // MARK: Test lifecycle
    
    override func setUp() {
        super.setUp()
        setupSettingsAlertSingleTypePresenter()
    }
    
    override func tearDown() {
        super.tearDown()
    }
    
    // MARK: Test setup
    
    func setupSettingsAlertSingleTypePresenter() {
        sut = SettingsAlertSingleTypePresenter()
    }
    
    // MARK: Test doubles
    
    final class SettingsAlertSingleTypeDisplayLogicSpy: SettingsAlertSingleTypeDisplayLogic {
        var displayLoadCalled = false
        
        func displayLoad(viewModel: SettingsAlertSingleType.Load.ViewModel) {
            displayLoadCalled = true
        }
    }
    
    // MARK: Tests
    
    func testPresentLoad() {
        // Given
        let spy = SettingsAlertSingleTypeDisplayLogicSpy()
        sut.viewController = spy
        let response = SettingsAlertSingleType.Load.Response(
            animated: false,
            settings: User.current.settings ?? Settings(),
            configuration: AlertConfiguration(),
            switchValueChangedHandler: { _, _ in },
            textEditingChangedHandler: { _ in },
            timePickerValueChangedHandler: { _, _ in },
            pickerViewValueChangedHandler: { _, _ in },
            selectionHandler: { }
        )
        
        // When
        sut.presentLoad(response: response)
        
        // Then
        XCTAssertTrue(
            spy.displayLoadCalled,
            "presentLoad(response:) should ask the view controller to display the result"
        )
    }
}
