You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.6 KiB
Kotlin
53 lines
1.6 KiB
Kotlin
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.fenix.ext
|
|
|
|
import androidx.navigation.NavController
|
|
import androidx.navigation.NavDestination
|
|
import androidx.navigation.NavDirections
|
|
import androidx.navigation.NavOptions
|
|
import io.mockk.MockKAnnotations
|
|
import io.mockk.every
|
|
import io.mockk.impl.annotations.MockK
|
|
import io.mockk.verify
|
|
import org.junit.Before
|
|
import org.junit.Test
|
|
|
|
class NavControllerTest {
|
|
|
|
private val currentDestId = 4
|
|
|
|
@MockK(relaxUnitFun = true)
|
|
private lateinit var navController: NavController
|
|
|
|
@MockK private lateinit var navDirections: NavDirections
|
|
|
|
@MockK private lateinit var mockDestination: NavDestination
|
|
|
|
@MockK private lateinit var mockOptions: NavOptions
|
|
|
|
@Before
|
|
fun setUp() {
|
|
MockKAnnotations.init(this)
|
|
|
|
every { navController.currentDestination } returns mockDestination
|
|
every { mockDestination.id } returns currentDestId
|
|
}
|
|
|
|
@Test
|
|
fun `Nav with id and directions args`() {
|
|
navController.nav(currentDestId, navDirections)
|
|
verify { navController.currentDestination }
|
|
verify { navController.navigate(navDirections, null) }
|
|
}
|
|
|
|
@Test
|
|
fun `Nav with id, directions, and options args`() {
|
|
navController.nav(currentDestId, navDirections, mockOptions)
|
|
verify { navController.currentDestination }
|
|
verify { navController.navigate(navDirections, mockOptions) }
|
|
}
|
|
}
|