Add tests
This commit is contained in:
parent
4efaa253b8
commit
dc62f9ce63
@ -22,7 +22,7 @@ public class KeyboardRow extends ArrayList<KeyboardButton> implements Validable
|
||||
}
|
||||
|
||||
public void addAll(List<String> buttonNames) {
|
||||
buttonNames.forEach(KeyboardButton::new);
|
||||
buttonNames.forEach(name -> super.add(new KeyboardButton(name)));
|
||||
}
|
||||
|
||||
public boolean contains(String text) {
|
||||
|
@ -0,0 +1,34 @@
|
||||
package org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class KeyboardRowTest {
|
||||
|
||||
private static final List<String> BUTTON_NAMES = asList("Carlotta Valdes", "Jimmy Stewart");
|
||||
|
||||
@Test
|
||||
public void shouldAddAllButtons() {
|
||||
final KeyboardRow keyboardRow = new KeyboardRow();
|
||||
keyboardRow.addAll(BUTTON_NAMES);
|
||||
assertThat(keyboardRow.size(), is(2));
|
||||
assertThat(keyboardRow.get(0).getText(), is("Carlotta Valdes"));
|
||||
assertThat(keyboardRow.get(1).getText(), is("Jimmy Stewart"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldAddNoButtons() {
|
||||
final KeyboardRow keyboardRow = new KeyboardRow();
|
||||
keyboardRow.addAll(new ArrayList<String>());
|
||||
assertTrue(keyboardRow.isEmpty());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user