Update tests for Compose alpha03

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-09-17 02:06:43 +05:30
parent 43e9b000d9
commit c75955a4a3
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -22,7 +22,8 @@ class MainActivityTest {
@Test @Test
fun item_add_dialog_shows_on_fab_click() { fun item_add_dialog_shows_on_fab_click() {
composeTestRule.setContent { composeTestRule.apply {
setContent {
TodoTheme { TodoTheme {
val items = arrayListOf<TodoItem>() val items = arrayListOf<TodoItem>()
TodoApp( TodoApp(
@ -35,10 +36,12 @@ class MainActivityTest {
onNodeWithTag("fab").performClick() onNodeWithTag("fab").performClick()
onNodeWithTag("item_dialog").assertIsDisplayed() onNodeWithTag("item_dialog").assertIsDisplayed()
} }
}
@Test @Test
fun item_addition_adds_new_entry() { fun item_addition_adds_new_entry() {
composeTestRule.setContent { composeTestRule.apply {
setContent {
val items by mutableStateOf(arrayListOf<TodoItem>()) val items by mutableStateOf(arrayListOf<TodoItem>())
TodoTheme { TodoTheme {
TodoApp( TodoApp(
@ -54,10 +57,12 @@ class MainActivityTest {
onNodeWithTag("add_button").performClick() onNodeWithTag("add_button").performClick()
onNodeWithText("Item 1").assertIsDisplayed() onNodeWithText("Item 1").assertIsDisplayed()
} }
}
@Test @Test
fun item_addition_with_empty_name_does_not_add_new_entry() { fun item_addition_with_empty_name_does_not_add_new_entry() {
composeTestRule.setContent { composeTestRule.apply {
setContent {
val items by mutableStateOf(arrayListOf<TodoItem>()) val items by mutableStateOf(arrayListOf<TodoItem>())
TodoTheme { TodoTheme {
TodoApp( TodoApp(
@ -72,4 +77,5 @@ class MainActivityTest {
onNodeWithTag("add_button").performClick() onNodeWithTag("add_button").performClick()
onNodeWithText("Item 1").assertDoesNotExist() onNodeWithText("Item 1").assertDoesNotExist()
} }
}
} }