diff --git a/src/test/java/TestEmojiPicker.java b/src/test/java/TestEmojiPicker.java index 4843226..1ad2632 100644 --- a/src/test/java/TestEmojiPicker.java +++ b/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 + } } }