diff --git a/src/test/java/TestEmojiPicker.java b/src/test/java/TestEmojiPicker.java index 5fe2c94..ad5aa2e 100644 --- a/src/test/java/TestEmojiPicker.java +++ b/src/test/java/TestEmojiPicker.java @@ -70,4 +70,24 @@ public class TestEmojiPicker { } } -} \ No newline at end of file + @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; + EmojiPicker.EmojiActionListener actionListener = (EmojiPicker.EmojiActionListener) button.getActionListeners()[0]; + + assertNotNull(actionListener); + + actionListener.actionPerformed(null); + assertEquals(button.getText(), textField.getText()); + } + } +} +