mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
Refactor Unit Test: Replace Unsafe Casting with Type-Safe Mocking for findViewById
>PR refactors the unit test for NearbyParentFragment by replacing unsafe casting in the findViewById mocking statements with type-safe >Ensured all findViewById mocks now use a consistent, type-safe format (findViewById<View>(...)) to reduce verbosity and potential casting errors. >Verified the functionality of prepareViewsForSheetPosition remains unchanged, ensuring no regression in test behavior.
This commit is contained in:
parent
83bef3a6b3
commit
abef27a7af
1 changed files with 4 additions and 4 deletions
|
|
@ -333,8 +333,8 @@ class NearbyParentFragmentUnitTest {
|
|||
fun testPrepareViewsForSheetPositionCaseCollapsed() {
|
||||
Whitebox.setInternalState(fragment, "isFABsExpanded", true)
|
||||
Whitebox.setInternalState(fragment, "mView", view)
|
||||
whenever(view.findViewById(R.id.empty_view) as View?).thenReturn(view)
|
||||
whenever(view.findViewById(R.id.empty_view1) as View?).thenReturn(view)
|
||||
whenever(view.findViewById<View>(R.id.empty_view)).thenReturn(view)
|
||||
whenever(view.findViewById<View>(R.id.empty_view1)).thenReturn(view)
|
||||
whenever(view.id).thenReturn(0)
|
||||
fragment.prepareViewsForSheetPosition(BottomSheetBehavior.STATE_COLLAPSED)
|
||||
verify(fab).isShown
|
||||
|
|
@ -345,8 +345,8 @@ class NearbyParentFragmentUnitTest {
|
|||
fun testPrepareViewsForSheetPositionCaseHidden() {
|
||||
Whitebox.setInternalState(fragment, "isFABsExpanded", true)
|
||||
Whitebox.setInternalState(fragment, "mView", view)
|
||||
whenever(view.findViewById(R.id.empty_view) as View?).thenReturn(view)
|
||||
whenever(view.findViewById(R.id.empty_view1) as View?).thenReturn(view)
|
||||
whenever(view.findViewById<View>(R.id.empty_view)).thenReturn(view)
|
||||
whenever(view.findViewById<View>(R.id.empty_view1)).thenReturn(view)
|
||||
whenever(view.id).thenReturn(0)
|
||||
whenever(fab.layoutParams).thenReturn(mock(CoordinatorLayout.LayoutParams::class.java))
|
||||
fragment.prepareViewsForSheetPosition(BottomSheetBehavior.STATE_HIDDEN)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue