Skip to content

Commit

Permalink
Also add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adudenamedruby committed Jul 15, 2024
1 parent a2a16f6 commit c51b2d4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,31 @@ final class BrowserCoordinatorTests: XCTestCase {
XCTAssertTrue(mockRouter.presentedViewController is BottomSheetViewController)
}

// MARK: - Menu
func testShowMainMenu_addsMainMenuCoordinator() {
let subject = createSubject()

subject.showMainMenu()

XCTAssertEqual(subject.childCoordinators.count, 1)
XCTAssertTrue(subject.childCoordinators.first is MainMenuCoordinator)
XCTAssertEqual(mockRouter.presentCalled, 1)
XCTAssertTrue(mockRouter.presentedViewController is MainMenuViewController)
}

func testMainMenuCoordinatorDelegate_didDidDismiss_removesChild() {
let subject = createSubject()
subject.browserHasLoaded()

subject.showMainMenu()
let menuCoordinator = subject.childCoordinators[0] as! MainMenuCoordinator
menuCoordinator.dismissModal(animated: false)

XCTAssertEqual(mockRouter.dismissCalled, 1)
XCTAssertTrue(subject.childCoordinators.isEmpty)
}

// MARK: - Microsurvey
func testShowMicrosurvey_addsMicrosurveyCoordinator() {
let subject = createSubject()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MockBrowserCoordinator: BrowserNavigationHandler, ParentCoordinatorDelegat
var dismissFakespotSidebarCalled = 0
var updateFakespotSidebarCalled = 0
var showMicrosurveyCalled = 0
var showMainMenuCalled = 0

func show(settings: Client.Route.SettingsSection, onDismiss: (() -> Void)?) {
showSettingsCalled += 1
Expand Down Expand Up @@ -100,6 +101,10 @@ class MockBrowserCoordinator: BrowserNavigationHandler, ParentCoordinatorDelegat
showFakespotFlowAsModalCalled += 1
}

func showMainMenu() {
showMainMenuCalled += 1
}

func showFakespotFlowAsSidebar(productURL: URL,
sidebarContainer: Client.SidebarEnabledViewProtocol,
parentViewController: UIViewController) {
Expand Down

0 comments on commit c51b2d4

Please sign in to comment.