1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.fenix.components.menu
7 import androidx.navigation.NavController
10 import kotlinx.coroutines.test.runTest
11 import mozilla.components.support.test.rule.MainCoroutineRule
12 import org.junit.Before
15 import org.mozilla.fenix.R
16 import org.mozilla.fenix.components.menu.middleware.MenuNavigationMiddleware
17 import org.mozilla.fenix.components.menu.store.MenuAction
18 import org.mozilla.fenix.components.menu.store.MenuState
19 import org.mozilla.fenix.components.menu.store.MenuStore
20 import org.mozilla.fenix.ext.nav
22 class MenuNavigationMiddlewareTest {
25 val coroutinesTestRule = MainCoroutineRule()
26 private val scope = coroutinesTestRule.scope
28 private val navController: NavController = mockk(relaxed = true)
30 private lateinit var store: MenuStore
31 private lateinit var middleware: MenuNavigationMiddleware
35 middleware = MenuNavigationMiddleware(
36 navController = navController,
40 initialState = MenuState(),
48 fun `WHEN navigate to settings action is dispatched THEN navigate to settings`() = runTest {
49 store.dispatch(MenuAction.Navigate.Settings).join()
53 R.id.menuDialogFragment,
54 MenuDialogFragmentDirections.actionGlobalSettingsFragment(),