From 5afefbff15141c6c31ef5f696d18bff70cd87569 Mon Sep 17 00:00:00 2001 From: Valentin Spiroski Date: Fri, 9 Feb 2024 22:43:29 +0100 Subject: [PATCH] refactoring:testEmojiPickerButtonText --- src/test/java/TestEmojiPicker.java | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/test/java/TestEmojiPicker.java b/src/test/java/TestEmojiPicker.java index 8179e87..cf7905e 100644 --- a/src/test/java/TestEmojiPicker.java +++ b/src/test/java/TestEmojiPicker.java @@ -33,23 +33,22 @@ public class TestEmojiPicker { assertEquals(12, components.length); // 12 buttons for 12 emojis } - + //Test to check if each emoji button contains valid emoji text @Test public void testEmojiPickerButtonText() { - - - JTextField textField = new JTextField(); - - EmojiPicker emojiPicker = new EmojiPicker(textField); - - Component[] components = emojiPicker.getComponents(); - - for (Component component : components) { - assertTrue(component instanceof JButton); + // Arrange + JTextField textField = new JTextField(); + EmojiPicker emojiPicker = new EmojiPicker(textField); - JButton button = (JButton) component; - assertTrue(button.getText().matches("[\uD83C-\uDBFF\uDC00-\uDFFF]+")); - } + // Act + Component[] components = emojiPicker.getComponents(); + + // Assert + for (Component component : components) { + assertTrue(component instanceof JButton); + JButton button = (JButton) component; + assertTrue(button.getText().matches("[\uD83C-\uDBFF\uDC00-\uDFFF]+")); // Check if button text is an emoji + } } @Test