File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
src/test/java/com/flowingcode/vaadin/addons/chipfield/integration Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1919 */
2020package com .flowingcode .vaadin .addons .chipfield .integration ;
2121
22+ import java .lang .reflect .Method ;
2223import java .util .Arrays ;
24+ import java .util .Optional ;
2325
2426import com .flowingcode .vaadin .addons .chipfield .ChipField ;
2527import com .flowingcode .vaadin .addons .chipfield .integration .rpc .JsonArrayList ;
@@ -97,4 +99,16 @@ public JsonArrayList<String> getValue() {
9799 return JsonArrayList .createArray (field .getValue (), Json ::create );
98100 }
99101
102+ @ Override
103+ @ ClientCallable
104+ public boolean hasItemWithLabel (String label ) {
105+ try {
106+ Method method = ChipField .class .getDeclaredMethod ("findItemByLabel" , String .class );
107+ method .setAccessible (true );
108+ return ((Optional <?>) method .invoke (field , label )).isPresent ();
109+ } catch (Exception e ) {
110+ throw new RuntimeException ();
111+ }
112+ }
113+
100114}
Original file line number Diff line number Diff line change @@ -39,4 +39,6 @@ public interface IntegrationViewCallables {
3939
4040 void removeSelectedItem (String itemToRemove );
4141
42+ boolean hasItemWithLabel (String label );
43+
4244}
Original file line number Diff line number Diff line change 2121
2222import static org .hamcrest .MatcherAssert .assertThat ;
2323import static org .junit .Assert .assertThrows ;
24+ import static org .junit .Assert .assertTrue ;
2425
2526import java .util .Arrays ;
2627import java .util .Collection ;
@@ -184,4 +185,15 @@ public void testRemoveSelectedItem() {
184185 assertThat ($server .getValue (), isEqualTo (IPSUM ));
185186 }
186187
188+ /**
189+ * Test that findItemByLabel returns the additional chip
190+ *
191+ * @see https://github.com/FlowingCode/ChipFieldAddon/issues/35
192+ */
193+ @ Test
194+ public void testFindItemByLabel () {
195+ $server .useNewItemHandler (true );
196+ chipfield .sendKeys (ADDITIONAL , Keys .ENTER );
197+ assertTrue ("Additional item was not returned by findItemByLabel" , $server .hasItemWithLabel (ADDITIONAL ));
198+ }
187199}
You can’t perform that action at this time.
0 commit comments