Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hichamboushaba committed Sep 11, 2024
1 parent 5749b6f commit 4be88f0
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,36 @@ class CustomFieldsEditorViewModelTest : BaseUnitTest() {
.isEqualTo(UiString.UiStringRes(R.string.custom_fields_editor_key_error_underscore))
assertThat(state.showDoneButton).isFalse()
}

@Test
fun `when tapping copy key, then copy key to clipboard`() = testBlocking {
setup(editing = true)

val event = viewModel.event.runAndCaptureValues {
viewModel.onCopyKeyClicked()
}.last()

assertThat(event).isEqualTo(
CustomFieldsEditorViewModel.CopyContentToClipboard(
R.string.custom_fields_editor_key_label,
CUSTOM_FIELD.key
)
)
}

@Test
fun `when tapping copy value, then copy value to clipboard`() = testBlocking {
setup(editing = true)

val event = viewModel.event.runAndCaptureValues {
viewModel.onCopyValueClicked()
}.last()

assertThat(event).isEqualTo(
CustomFieldsEditorViewModel.CopyContentToClipboard(
R.string.custom_fields_editor_value_label,
CUSTOM_FIELD.valueAsString
)
)
}
}

0 comments on commit 4be88f0

Please sign in to comment.