fix: code review notes
This commit is contained in:
parent
22b133648b
commit
270ac1a4d5
|
|
@ -91,6 +91,7 @@ LICENSE
|
|||
- [TIUIElements](docs/tiuielements)
|
||||
* [Skeletons](docs/tiuielements/skeletons.md)
|
||||
* [Placeholders](docs/tiuielements/placeholder.md)
|
||||
- [TIDeeplink](docs/tideeplink/deeplinks.md)
|
||||
- [Semantic Commit Messages](docs/semantic-commit-messages.md) - commit message codestyle.
|
||||
- [Snippets](docs/snippets.md) - useful commands and scripts for development.
|
||||
|
||||
|
|
|
|||
|
|
@ -23,10 +23,11 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
|
||||
open class BaseNavigationStackDeeplinkHandler<RootViewController: DeeplinkHandlerViewController>: DeeplinkHandler {
|
||||
public var rootViewControllerKeeper: RootViewController
|
||||
open class BaseNavigationStackDeeplinkHandler: DeeplinkHandler {
|
||||
|
||||
public init(rootViewControllerKeeper: RootViewController) {
|
||||
public var rootViewControllerKeeper: UIViewController
|
||||
|
||||
public init(rootViewControllerKeeper: UIViewController) {
|
||||
self.rootViewControllerKeeper = rootViewControllerKeeper
|
||||
}
|
||||
// MARK: - DeeplinkHandler
|
||||
|
|
|
|||
|
|
@ -22,11 +22,8 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
public typealias DeeplinkHandlerViewController = DeeplinkHandler & UIViewController
|
||||
|
||||
public extension UIViewController {
|
||||
func findHandler(for deeplink: Deeplink) -> DeeplinkHandler? {
|
||||
|
||||
if let deeplinksHandler = self as? DeeplinkHandler,
|
||||
let _ = deeplinksHandler.handle(deeplink: deeplink) {
|
||||
return deeplinksHandler
|
||||
|
|
|
|||
|
|
@ -104,13 +104,6 @@ application(.shared, open: url)
|
|||
/*:
|
||||
В качестве `DeeplinkHandler` можно использовать базовую реализацию `BaseNavigationStackDeeplinkHandler`, которая позволяет искать handler в иерархии view, способный обработать диплинк
|
||||
*/
|
||||
class NavigationController: UINavigationController, DeeplinkHandler {
|
||||
|
||||
func handle(deeplink: Deeplink) -> Foundation.Operation? {
|
||||
nil
|
||||
}
|
||||
}
|
||||
|
||||
class ViewController: UIViewController, DeeplinkHandler {
|
||||
func handle(deeplink: Deeplink) -> Operation? {
|
||||
if deeplink == .editProfile {
|
||||
|
|
@ -130,11 +123,9 @@ class ViewController: UIViewController, DeeplinkHandler {
|
|||
}
|
||||
|
||||
//: Создание Handler. Для настройки передается rootViewController, который должен наследоваться от `UIViewController` и соответствовать протоколу `DeeplinkHandler`. С этого контроллера будет начинаться поиск обработчика
|
||||
typealias ProjectNavigationStackDeeplinkHandler = BaseNavigationStackDeeplinkHandler<NavigationController>
|
||||
|
||||
let viewController = ViewController()
|
||||
let navigationController = NavigationController(rootViewController: viewController)
|
||||
let handler = ProjectNavigationStackDeeplinkHandler(rootViewControllerKeeper: navigationController)
|
||||
let navigationController = UINavigationController(rootViewController: viewController)
|
||||
let handler = BaseNavigationStackDeeplinkHandler(rootViewControllerKeeper: navigationController)
|
||||
|
||||
//: Далее handler может передаваться для использования в `TIDeeplinksService`
|
||||
let service = TIDeeplinksService(mapper: mapper, handler: handler)
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
import Foundation
|
||||
import XCTest
|
||||
|
||||
public extension Nef {
|
||||
|
||||
static func run<T: XCTestCase>(testCase class: T.Type) {
|
||||
startTestObserver()
|
||||
T.defaultTestSuite.run()
|
||||
}
|
||||
|
||||
static private func startTestObserver() {
|
||||
_ = testObserverInstalled
|
||||
}
|
||||
|
||||
static private var testObserverInstalled = { () -> NefTestFailObserver in
|
||||
let testObserver = NefTestFailObserver()
|
||||
XCTestObservationCenter.shared.addTestObserver(testObserver)
|
||||
return testObserver
|
||||
}()
|
||||
}
|
||||
|
||||
// MARK: enrich the output for XCTest
|
||||
fileprivate class NefTestFailObserver: NSObject, XCTestObservation {
|
||||
|
||||
private var numberOfFailedTests = 0
|
||||
|
||||
func testSuiteWillStart(_ testSuite: XCTestSuite) {
|
||||
numberOfFailedTests = 0
|
||||
}
|
||||
|
||||
func testSuiteDidFinish(_ testSuite: XCTestSuite) {
|
||||
if numberOfFailedTests > 0 {
|
||||
print("💢 Test Suite '\(testSuite.name)' finished with \(numberOfFailedTests) failed \(numberOfFailedTests > 1 ? "tests" : "test").")
|
||||
} else {
|
||||
print("🔅 Test Suite '\(testSuite.name)' finished successfully.")
|
||||
}
|
||||
}
|
||||
|
||||
func testCase(_ testCase: XCTestCase,
|
||||
didFailWithDescription description: String,
|
||||
inFile filePath: String?,
|
||||
atLine lineNumber: Int) {
|
||||
|
||||
numberOfFailedTests += 1
|
||||
print("❗️Test Fail '\(testCase.name)':\(UInt(lineNumber)): \(description.description)")
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue