Skip to content

Commit c9d08a1

Browse files
committed
test: add regression test for #27
Test that removeSelectedItem actually removes the item.
1 parent b42eff9 commit c9d08a1

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/test/java/com/flowingcode/vaadin/addons/chipfield/integration/IntegrationView.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ public void allowAdditionalItems(boolean value) {
5454
field.setAllowAdditionalItems(value);
5555
}
5656

57+
@Override
58+
@ClientCallable
59+
public void removeSelectedItem(String itemToRemove) {
60+
field.removeSelectedItem(itemToRemove);
61+
}
62+
5763
@Override
5864
@ClientCallable
5965
public void setFieldReadOnly(boolean value) {

src/test/java/com/flowingcode/vaadin/addons/chipfield/integration/IntegrationViewCallables.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ public interface IntegrationViewCallables {
3737

3838
JsonArrayList<String> getValue();
3939

40+
void removeSelectedItem(String itemToRemove);
41+
4042
}

src/test/java/com/flowingcode/vaadin/addons/chipfield/integration/ViewIT.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -171,4 +171,17 @@ public void testSetValue() {
171171
assertThat($server.getValue(), isEqualTo(IPSUM, LOREM));
172172
}
173173

174+
/**
175+
* Test that removeSelectedItem actually removes the item.
176+
*
177+
* @see https://github.com/FlowingCode/ChipFieldAddon/issues/27
178+
*/
179+
@Test
180+
public void testRemoveSelectedItem() {
181+
$server.setValue(LOREM, IPSUM);
182+
$server.removeSelectedItem(LOREM);
183+
assertThat(chipfield.getValue(), isEqualTo(IPSUM));
184+
assertThat($server.getValue(), isEqualTo(IPSUM));
185+
}
186+
174187
}

0 commit comments

Comments
 (0)