From 272f0d1d99cc6b722f05a2bfe476249cb8d8c7b8 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Tue, 8 Sep 2020 05:59:49 +0530 Subject: [PATCH] Add test to ensure new item is not added if name is empty Signed-off-by: Harsh Shandilya --- .../dev/msfjarvis/todo/MainActivityTest.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/androidTest/java/dev/msfjarvis/todo/MainActivityTest.kt b/app/src/androidTest/java/dev/msfjarvis/todo/MainActivityTest.kt index 0c287613..1439d455 100644 --- a/app/src/androidTest/java/dev/msfjarvis/todo/MainActivityTest.kt +++ b/app/src/androidTest/java/dev/msfjarvis/todo/MainActivityTest.kt @@ -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()) + TodoTheme { + TodoApp( + items, + items::add, + items::remove, + ) + } + } + onNodeWithText("Item 1").assertDoesNotExist() + onNodeWithTag("fab").performClick() + onNodeWithTag("add_button").performClick() + onNodeWithText("Item 1").assertDoesNotExist() + } }