From 4e4755aba5729eafcbf1489e4637855811360d1c Mon Sep 17 00:00:00 2001 From: Valentin Spiroski Date: Fri, 9 Feb 2024 22:44:51 +0100 Subject: [PATCH] refactoring:testEmojiPickerActionListener --- src/test/java/TestEmojiPicker.java | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/test/java/TestEmojiPicker.java b/src/test/java/TestEmojiPicker.java index cf7905e..4843226 100644 --- a/src/test/java/TestEmojiPicker.java +++ b/src/test/java/TestEmojiPicker.java @@ -51,24 +51,24 @@ public class TestEmojiPicker { } } + // Test to ensure each emoji button has an EmojiActionListener attached @Test public void testEmojiPickerActionListener() { + // Arrange + JTextField textField = new JTextField(); + EmojiPicker emojiPicker = new EmojiPicker(textField); - 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; - assertNotNull(button.getActionListeners()); - - assertEquals(1, button.getActionListeners().length); - assertTrue(button.getActionListeners()[0] instanceof EmojiPicker.EmojiActionListener); - } + // Act + Component[] components = emojiPicker.getComponents(); + + // Assert + for (Component component : components) { + assertTrue(component instanceof JButton); + JButton button = (JButton) component; + assertNotNull(button.getActionListeners()); + assertEquals(1, button.getActionListeners().length); + assertTrue(button.getActionListeners()[0] instanceof EmojiPicker.EmojiActionListener); + } } @Test