Skip to content

Commit

Permalink
cleaned up old state for dropdown (#1779)
Browse files Browse the repository at this point in the history
* cleaned up Old State for dropdown

* testcase added
  • Loading branch information
PallaviGanorkar committed Jan 5, 2023
1 parent 0ec9496 commit 87c69f6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,31 @@ class QuestionnaireItemDropDownViewHolderFactoryEspressoTest {
assertThat((answerHolder!!.single().value as Coding).display).isEqualTo("Coding 3")
}

@Test
fun shouldClearAutoCompleteTextViewOnRebindingView() {
var answerHolder: List<QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent>? = null
val questionnaireItemViewItem =
QuestionnaireItemViewItem(
answerOptions("Coding 1", "Coding 2", "Coding 3", "Coding 4", "Coding 5"),
responseOptions(),
validationResult = NotValidated,
answersChangedCallback = { _, _, answers -> answerHolder = answers },
)
runOnUI { viewHolder.bind(questionnaireItemViewItem) }

onView(withId(R.id.auto_complete)).perform(showDropDown())
onView(withText("Coding 3"))
.inRoot(isPlatformPopup())
.check(matches(isDisplayed()))
.perform(click())
assertThat(viewHolder.itemView.findViewById<TextView>(R.id.auto_complete).text.toString())
.isEqualTo("Coding 3")

runOnUI { viewHolder.bind(questionnaireItemViewItem) }
assertThat(viewHolder.itemView.findViewById<TextView>(R.id.auto_complete).text.toString())
.isEqualTo("")
}

@Test
fun shouldSetDropDownValueStringToAutoCompleteTextView() {
var answerHolder: List<QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent>? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ internal object QuestionnaireItemDropDownViewHolderFactory :

private fun cleanupOldState() {
autoCompleteTextView.setAdapter(null)
autoCompleteTextView.text = null
}
}
}

0 comments on commit 87c69f6

Please sign in to comment.