Skip to content

Commit

Permalink
BIT-174 Removes optional child navigators
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-livefront committed Sep 5, 2023
1 parent 4dddce6 commit 0faa907
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public protocol RootNavigator: Navigator {
/// Shows the specified child navigator.
///
/// - Parameter child: The navigator to show.
func show(child: Navigator?)
func show(child: Navigator)
}

// MARK: - RootViewController
Expand All @@ -19,7 +19,7 @@ extension RootViewController: RootNavigator {
self
}

public func show(child: Navigator?) {
childViewController = child?.rootViewController
public func show(child: Navigator) {
childViewController = child.rootViewController
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ class RootViewControllerTests: BitwardenTestCase {
subject.childViewController = viewController
XCTAssertIdentical(subject.rootViewController, subject)
}

/// `show(child:)` sets `childViewController` to the `rootViewController` on the child navigator.
func test_show() {
let navigator = MockStackNavigator()
navigator.rootViewController = UIViewController()
subject.show(child: navigator)
XCTAssertIdentical(subject.childViewController, navigator.rootViewController)
}
}
2 changes: 1 addition & 1 deletion GlobalTestHelpers/MockRootNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ final class MockRootNavigator: RootNavigator {
var navigatorShown: Navigator?
var rootViewController: UIViewController?

func show(child: Navigator?) {
func show(child: Navigator) {
navigatorShown = child
}
}

0 comments on commit 0faa907

Please sign in to comment.