Browse Source

refactoring:testEmojiPickerActionListenerFunctionality

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

25
src/test/java/TestEmojiPicker.java

@ -71,24 +71,23 @@ public class TestEmojiPicker {
}
}
//Test to verify the functionality of EmojiActionListener for each emoji button
@Test
public void testEmojiPickerActionListenerFunctionality() {
JTextField textField = new JTextField();
EmojiPicker emojiPicker = new EmojiPicker(textField);
Component[] components = emojiPicker.getComponents();
for (Component component : components) {
assertTrue(component instanceof JButton);
JButton button = (JButton) component;
// Arrange
JTextField textField = new JTextField();
EmojiPicker emojiPicker = new EmojiPicker(textField);
Component[] components = emojiPicker.getComponents();
// Act & Assert
for (Component component : components) {
assertTrue(component instanceof JButton);
JButton button = (JButton) component;
EmojiPicker.EmojiActionListener actionListener = (EmojiPicker.EmojiActionListener) button.getActionListeners()[0];
assertNotNull(actionListener);
actionListener.actionPerformed(null);
assertEquals(button.getText(), textField.getText());
}
assertEquals(button.getText(), textField.getText()); // Check if emoji is appended to the text field
}
}
}
Loading…
Cancel
Save