Skip to content

Commit

Permalink
Merge pull request #38 from allaboutapps/coordinator-no-default-value…
Browse files Browse the repository at this point in the history
…-in-init

Removed default parameter value in (Navigation)Coordinator
  • Loading branch information
mbuchetics authored Aug 16, 2023
2 parents b5899a1 + 80ea7a6 commit 79fad70
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
test:
name: Run unit tests
runs-on: macOS-latest
runs-on: macOS-13
steps:
- name: Checkout repository
uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let package = Package(
name: "Toolbox",
platforms: [
.iOS(.v14),
.macOS(.v10_15)
.macOS(.v11)
],
products: [
.library(
Expand Down
4 changes: 2 additions & 2 deletions Sources/Toolbox/Coordinators/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ open class Coordinator: NSObject {
public let rootViewController: UIViewController
var isPresented: Bool = false

public init(rootViewController: UIViewController? = nil) {
self.rootViewController = rootViewController ?? UIViewController()
public init(rootViewController: UIViewController) {
self.rootViewController = rootViewController

super.init()
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Toolbox/Coordinators/NavigationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ open class NavigationCoordinator: Coordinator {
return childCoordinators.first
}

public init(navigationController: UINavigationController? = nil) {
public init(navigationController: UINavigationController) {
self.pushedViewControllers = WeakArray([])
self.navigationController = navigationController ?? UINavigationController()
self.navigationController = navigationController

super.init(rootViewController: self.navigationController)
super.init(rootViewController: navigationController)

if self.navigationController.delegate == nil {
self.navigationController.delegate = self
Expand Down
24 changes: 5 additions & 19 deletions Tests/ToolboxTests/NavigationCoordinatorTests.swift
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
#if canImport(UIKit)

@testable import Toolbox
import XCTest

final class NavigationCoordinatorTests: XCTestCase {

func testNavigationCoordinatorInitialization() async throws {
let expectation = XCTestExpectation(description: "NavigationCoordinator initialization")

// Switch to the main actor context.
await MainActor.run {
let navCoordinator = NavigationCoordinator()

// Test your coordinator instance here, e.g.:
XCTAssertNotNil(navCoordinator)

// Fulfill the expectation when the test is complete.
expectation.fulfill()
}

// Wait for the expectation to be fulfilled.
await fulfillment(of: [expectation], timeout: 10)
}

func testNavigationCoordinatorRootIsUINavigationController() async throws {
let expectation = XCTestExpectation(description: "NavigationCoordinator initialization")

// Switch to the main actor context.
await MainActor.run {
let navCoordinator = NavigationCoordinator()
let navCoordinator = NavigationCoordinator(navigationController: .init())

// Test your coordinator instance here, e.g.:
XCTAssertNotNil(navCoordinator)
Expand All @@ -43,3 +27,5 @@ final class NavigationCoordinatorTests: XCTestCase {
}

}

#endif
22 changes: 4 additions & 18 deletions Tests/ToolboxTests/TabBarCoordinatorTests.swift
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
#if canImport(UIKit)

@testable import Toolbox
import XCTest

final class TabBarCoordinatorTests: XCTestCase {

func testTabBarCoordinatorInitialization() async throws {
let expectation = XCTestExpectation(description: "TabBarCoordinator initialization")

// Switch to the main actor context.
await MainActor.run {
let mainCoordinator = TabBarCoordinator()

// Test your coordinator instance here, e.g.:
XCTAssertNotNil(mainCoordinator)

// Fulfill the expectation when the test is complete.
expectation.fulfill()
}

// Wait for the expectation to be fulfilled.
await fulfillment(of: [expectation], timeout: 10)
}

func testTabBarCoordinatorRootIsUITabBarController() async throws {
let expectation = XCTestExpectation(description: "TabBarCoordinator initialization")
Expand All @@ -42,3 +26,5 @@ final class TabBarCoordinatorTests: XCTestCase {
await fulfillment(of: [expectation], timeout: 10)
}
}

#endif
4 changes: 4 additions & 0 deletions Tests/ToolboxTests/UIColorTests.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if canImport(UIKit)

import UIKit
@testable import Toolbox
import XCTest
Expand Down Expand Up @@ -64,3 +66,5 @@ final class UIColorTests: XCTestCase {
XCTAssertEqual(color.toHexString().uppercased(), "#ABCDEF")
}
}

#endif

0 comments on commit 79fad70

Please sign in to comment.