Skip to content

Commit

Permalink
fix: allow lenient mockito stubs for ConfigTriggerViewModelTest
Browse files Browse the repository at this point in the history
  • Loading branch information
sds100 committed Jan 19, 2025
1 parent 0bbfa1a commit b3f6fad
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.mockito.junit.MockitoJUnitRunner
import org.mockito.kotlin.any
import org.mockito.kotlin.mock


/**
* Created by sds100 on 28/04/2021.
*/
Expand Down Expand Up @@ -82,7 +83,7 @@ class ConfigTriggerViewModelTest {
onBlocking { getTriggerErrors(any()) }.thenReturn(emptyList())
},
fakeResourceProvider,
purchasingManager = mock {
purchasingManager = mock(lenient = true) {
onBlocking { isPurchased(ProductId.ASSISTANT_TRIGGER) }.thenReturn(Success(false))
onBlocking { getProductPrice(ProductId.ASSISTANT_TRIGGER) }.thenReturn(Success(""))
},
Expand All @@ -94,21 +95,22 @@ class ConfigTriggerViewModelTest {
* issue #602
*/
@Test
fun `when create back button trigger key then prompt the user to disable screen pinning`() = runTest(testDispatcher) {
// GIVEN
fakeResourceProvider.stringResourceMap[R.string.dialog_message_screen_pinning_warning] =
"bla"

// WHEN
onRecordKey.emit(
RecordedKey(
keyCode = KeyEvent.KEYCODE_BACK,
device = TriggerKeyDevice.Internal,
detectionSource = KeyEventDetectionSource.ACCESSIBILITY_SERVICE,
),
)
fun `when create back button trigger key then prompt the user to disable screen pinning`() =
runTest(testDispatcher) {
// GIVEN
fakeResourceProvider.stringResourceMap[R.string.dialog_message_screen_pinning_warning] =
"bla"

// THEN
assertThat(viewModel.showPopup.first().ui, `is`(PopupUi.Ok("bla")))
}
// WHEN
onRecordKey.emit(
RecordedKey(
keyCode = KeyEvent.KEYCODE_BACK,
device = TriggerKeyDevice.Internal,
detectionSource = KeyEventDetectionSource.ACCESSIBILITY_SERVICE,
),
)

// THEN
assertThat(viewModel.showPopup.first().ui, `is`(PopupUi.Ok("bla")))
}
}

0 comments on commit b3f6fad

Please sign in to comment.