diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/BrowserCoordinatorTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/BrowserCoordinatorTests.swift index c182a5913fe5..c7a39122693b 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/BrowserCoordinatorTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/BrowserCoordinatorTests.swift @@ -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() diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Mocks/MockBrowserCoordinator.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Mocks/MockBrowserCoordinator.swift index 415208451315..775d9a87f1a2 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Mocks/MockBrowserCoordinator.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Mocks/MockBrowserCoordinator.swift @@ -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 @@ -100,6 +101,10 @@ class MockBrowserCoordinator: BrowserNavigationHandler, ParentCoordinatorDelegat showFakespotFlowAsModalCalled += 1 } + func showMainMenu() { + showMainMenuCalled += 1 + } + func showFakespotFlowAsSidebar(productURL: URL, sidebarContainer: Client.SidebarEnabledViewProtocol, parentViewController: UIViewController) {