Skip to content

Commit

Permalink
Clarify default visit options
Browse files Browse the repository at this point in the history
  • Loading branch information
olivaresf committed May 14, 2024
1 parent 76a35d0 commit 7af0efa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Source/Turbo Navigator/TurboNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public class TurboNavigator {
/// Convenience function to routing a proposal directly.
///
/// - Parameter url: the URL to visit
/// - Parameter options: passed options will override any from the path configuration
/// - Parameter options: passed options will override default `advance` visit options
/// - Parameter parameters: provide context relevant to `url`
public func route(_ url: URL,
options: VisitOptions = VisitOptions(action: .advance),
options: VisitOptions? = VisitOptions(action: .advance),
parameters: [String: Any]? = nil) {
let properties = session.pathConfiguration?.properties(for: url) ?? PathProperties()
route(VisitProposal(url: url,
options: options,
options: options ?? .init(action: .advance),
properties: properties,
parameters: parameters))
}
Expand Down
13 changes: 12 additions & 1 deletion Tests/Turbo Navigator/TurboNavigatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class TurboNavigationHierarchyControllerTests: XCTestCase {
loadNavigationControllerInWindow()
}

func test_default_default_default_pushesOnMainStack() {
func test_default_default_default_defaultOptionsParamater_pushesOnMainStack() {
navigator.route(oneURL)
XCTAssertEqual(navigationController.viewControllers.count, 1)
XCTAssert(navigator.rootViewController.viewControllers.last is VisitableViewController)
Expand All @@ -27,6 +27,17 @@ final class TurboNavigationHierarchyControllerTests: XCTestCase {
XCTAssert(navigator.rootViewController.viewControllers.last is VisitableViewController)
assertVisited(url: twoURL, on: .main)
}

func test_default_default_default_nilOptionsParameter_pushesOnMainStack() {
navigator.route(oneURL)
XCTAssertEqual(navigationController.viewControllers.count, 1)
XCTAssert(navigator.rootViewController.viewControllers.last is VisitableViewController)

navigator.route(twoURL, options: nil)
XCTAssertEqual(navigationController.viewControllers.count, 2)
XCTAssert(navigator.rootViewController.viewControllers.last is VisitableViewController)
assertVisited(url: twoURL, on: .main)
}

func test_default_default_default_visitingSamePage_replacesOnMainStack() {
navigator.route(oneURL)
Expand Down

0 comments on commit 7af0efa

Please sign in to comment.