Skip to content

Instantly share code, notes, and snippets.

@brunomunizaf
Created November 3, 2020 18:31
Show Gist options
  • Select an option

  • Save brunomunizaf/21747b6f3490d2f92c692b246fb6142f to your computer and use it in GitHub Desktop.

Select an option

Save brunomunizaf/21747b6f3490d2f92c692b246fb6142f to your computer and use it in GitHub Desktop.
import Quick
import Nimble
@testable import myapp
final class PusherDouble: Pushing {
private(set) var didPresentTarget: UIViewController?
private(set) var didPresentFrom: UIViewController?
}
extension PusherDouble {
func push(_ target: UIViewController, from parent: UIViewController) {
didPresentFrom = parent
didPresentTarget = target
}
}
final class DashboardCoordinatorSpec: QuickSpec {
override func spec() {
context("init") {
var sut: DashboardCoordinator!
var pusherDouble: PusherDouble!
beforeEach() {
pusherDouble = PusherDouble()
sut = DashboardCoordinator()
sut.pusher = pusherDouble
}
context("when pushing dashboard screen") {
var parent: UIViewController!
var dashboardScreen: UIViewController!
beforeEach() {
parent = UIViewController()
dashboardScreen = UIViewController()
sut.dashboardScreenFactory = { dashboardScreen }
sut.pushDashboardScreen(from: parent)
}
it("should push from the parent screen and the correct target") {
expect(pusherDouble.didPresentFrom) === parent
expect(pusherDouble.didPresentTarget) === dashboardScreen
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment