Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-livefront committed Dec 11, 2024
1 parent f184cba commit 7f70f87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ class ItemListingViewModel @Inject constructor(

private fun handleItemClick(authCode: String) {
clipboardManager.setText(authCode)
sendEvent(
ItemListingEvent.ShowToast(
message = R.string.value_has_been_copied.asText(authCode),
),
)
}

private fun handleEditItemClick(itemId: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,25 +435,20 @@ class ItemListingViewModelTest : BaseViewModelTest() {
@Test
fun `should copy text to clipboard when DropdownMenuClick COPY is triggered`() = runTest {
val viewModel = createViewModel()
val testId = "123456"

every { clipboardManager.setText(text = testId) } just runs
every { clipboardManager.setText(text = LOCAL_CODE.authCode) } just runs

viewModel.eventFlow.test {
viewModel.trySendAction(
ItemListingAction.DropdownMenuClick(VaultDropdownMenuAction.COPY, LOCAL_CODE),
ItemListingAction.DropdownMenuClick(
menuAction = VaultDropdownMenuAction.COPY,
item = LOCAL_CODE,
),
)

verify(exactly = 1) {
clipboardManager.setText(text = LOCAL_CODE.authCode)
}

assertEquals(
ItemListingEvent.ShowToast(
message = R.string.value_has_been_copied.asText(testId),
),
awaitItem(),
)
}
}

Expand Down Expand Up @@ -485,7 +480,10 @@ class ItemListingViewModelTest : BaseViewModelTest() {
)

viewModel.trySendAction(
ItemListingAction.DropdownMenuClick(VaultDropdownMenuAction.DELETE, LOCAL_CODE),
ItemListingAction.DropdownMenuClick(
menuAction = VaultDropdownMenuAction.DELETE,
item = LOCAL_CODE,
),
)

assertEquals(
Expand Down

0 comments on commit 7f70f87

Please sign in to comment.