File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
src/test/java/com/flowingcode/vaadin/addons/chipfield/integration Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -40,4 +40,10 @@ public void sendKeys(CharSequence... keysToSend) {
4040 public void selectByText (String label ) {
4141 sendKeys (label , Keys .ARROW_DOWN , Keys .ENTER );
4242 }
43+
44+ public void click (int index ) {
45+ TestBenchElement chip = $ ("paper-chip" ).get (index );
46+ executeScript ("arguments[0].root.querySelector('.chip').click()" , chip );
47+ }
48+
4349}
Original file line number Diff line number Diff line change 2222import static org .hamcrest .MatcherAssert .assertThat ;
2323import static org .junit .Assert .assertThrows ;
2424import static org .junit .Assert .assertTrue ;
25-
2625import java .util .Arrays ;
2726import java .util .Collection ;
2827import org .hamcrest .Matcher ;
@@ -203,6 +202,27 @@ public void testAdditionalItemRemovedListenerFromServer() {
203202 $server .setValue ();
204203 assertThat ($server .getLastRemovedItem (), Matchers .is (ADDITIONAL ));
205204 }
205+
206+ @ Test
207+ public void testItemClickedListener () {
208+ $server .addItemClickedListener ();
209+
210+ $server .setValue (LOREM );
211+ chipfield .click (0 );
212+ assertThat ($server .getLastClickedItem (), Matchers .is (LOREM ));
213+ }
214+
215+ @ Test
216+ public void testAdditionalItemClickedListener () {
217+ $server .allowAdditionalItems (true );
218+ $server .useNewItemHandler (true );
219+ $server .addItemClickedListener ();
220+
221+ $server .setValue (ADDITIONAL );
222+ chipfield .click (0 );
223+ assertThat ($server .getLastClickedItem (), Matchers .is (ADDITIONAL ));
224+ }
225+
206226 /**
207227 * Test that readonly does not allow deleting chips
208228 *
You can’t perform that action at this time.
0 commit comments