Created
November 3, 2020 18:31
-
-
Save brunomunizaf/21747b6f3490d2f92c692b246fb6142f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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