Add test to ensure new item is not added if name is empty

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-09-08 05:59:49 +05:30
parent 0ccd3b353d
commit 272f0d1d99
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -52,4 +52,22 @@ class MainActivityTest {
onNodeWithTag("add_button").performClick()
onNodeWithText("Item 1").assertIsDisplayed()
}
@Test
fun item_addition_with_empty_name_does_not_add_new_entry() {
composeTestRule.setContent {
val items by mutableStateOf(arrayListOf<TodoItem>())
TodoTheme {
TodoApp(
items,
items::add,
items::remove,
)
}
}
onNodeWithText("Item 1").assertDoesNotExist()
onNodeWithTag("fab").performClick()
onNodeWithTag("add_button").performClick()
onNodeWithText("Item 1").assertDoesNotExist()
}
}