mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 23:47:02 +05:30
Update tests for Compose alpha03
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
43e9b000d9
commit
c75955a4a3
1 changed files with 41 additions and 35 deletions
|
@ -22,54 +22,60 @@ class MainActivityTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun item_add_dialog_shows_on_fab_click() {
|
fun item_add_dialog_shows_on_fab_click() {
|
||||||
composeTestRule.setContent {
|
composeTestRule.apply {
|
||||||
TodoTheme {
|
setContent {
|
||||||
val items = arrayListOf<TodoItem>()
|
TodoTheme {
|
||||||
TodoApp(
|
val items = arrayListOf<TodoItem>()
|
||||||
items,
|
TodoApp(
|
||||||
items::add,
|
items,
|
||||||
items::remove,
|
items::add,
|
||||||
)
|
items::remove,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
onNodeWithTag("fab").performClick()
|
||||||
|
onNodeWithTag("item_dialog").assertIsDisplayed()
|
||||||
}
|
}
|
||||||
onNodeWithTag("fab").performClick()
|
|
||||||
onNodeWithTag("item_dialog").assertIsDisplayed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun item_addition_adds_new_entry() {
|
fun item_addition_adds_new_entry() {
|
||||||
composeTestRule.setContent {
|
composeTestRule.apply {
|
||||||
val items by mutableStateOf(arrayListOf<TodoItem>())
|
setContent {
|
||||||
TodoTheme {
|
val items by mutableStateOf(arrayListOf<TodoItem>())
|
||||||
TodoApp(
|
TodoTheme {
|
||||||
items,
|
TodoApp(
|
||||||
items::add,
|
items,
|
||||||
items::remove,
|
items::add,
|
||||||
)
|
items::remove,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
onNodeWithText("Item 1").assertDoesNotExist()
|
||||||
|
onNodeWithTag("fab").performClick()
|
||||||
|
onNodeWithTag("item_name").performTextInput("Item 1")
|
||||||
|
onNodeWithTag("add_button").performClick()
|
||||||
|
onNodeWithText("Item 1").assertIsDisplayed()
|
||||||
}
|
}
|
||||||
onNodeWithText("Item 1").assertDoesNotExist()
|
|
||||||
onNodeWithTag("fab").performClick()
|
|
||||||
onNodeWithTag("item_name").performTextInput("Item 1")
|
|
||||||
onNodeWithTag("add_button").performClick()
|
|
||||||
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 {
|
||||||
val items by mutableStateOf(arrayListOf<TodoItem>())
|
setContent {
|
||||||
TodoTheme {
|
val items by mutableStateOf(arrayListOf<TodoItem>())
|
||||||
TodoApp(
|
TodoTheme {
|
||||||
items,
|
TodoApp(
|
||||||
items::add,
|
items,
|
||||||
items::remove,
|
items::add,
|
||||||
)
|
items::remove,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
onNodeWithText("Item 1").assertDoesNotExist()
|
||||||
|
onNodeWithTag("fab").performClick()
|
||||||
|
onNodeWithTag("add_button").performClick()
|
||||||
|
onNodeWithText("Item 1").assertDoesNotExist()
|
||||||
}
|
}
|
||||||
onNodeWithText("Item 1").assertDoesNotExist()
|
|
||||||
onNodeWithTag("fab").performClick()
|
|
||||||
onNodeWithTag("add_button").performClick()
|
|
||||||
onNodeWithText("Item 1").assertDoesNotExist()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue