Browse Source

refactoring:testEmojiPickerButtonText

remotes/origin/client-handler
Valentin Spiroski 11 months ago
parent
commit
5afefbff15
  1. 11
      src/test/java/TestEmojiPicker.java

11
src/test/java/TestEmojiPicker.java

@ -33,22 +33,21 @@ public class TestEmojiPicker {
assertEquals(12, components.length); // 12 buttons for 12 emojis assertEquals(12, components.length); // 12 buttons for 12 emojis
} }
//Test to check if each emoji button contains valid emoji text
@Test @Test
public void testEmojiPickerButtonText() { public void testEmojiPickerButtonText() {
// Arrange
JTextField textField = new JTextField(); JTextField textField = new JTextField();
EmojiPicker emojiPicker = new EmojiPicker(textField); EmojiPicker emojiPicker = new EmojiPicker(textField);
// Act
Component[] components = emojiPicker.getComponents(); Component[] components = emojiPicker.getComponents();
// Assert
for (Component component : components) { for (Component component : components) {
assertTrue(component instanceof JButton); assertTrue(component instanceof JButton);
JButton button = (JButton) component; JButton button = (JButton) component;
assertTrue(button.getText().matches("[\uD83C-\uDBFF\uDC00-\uDFFF]+"));
assertTrue(button.getText().matches("[\uD83C-\uDBFF\uDC00-\uDFFF]+")); // Check if button text is an emoji
} }
} }

Loading…
Cancel
Save