Browse Source

refactoring:testEmojiPickerActionListener

remotes/origin/client-handler
Valentin Spiroski 11 months ago
parent
commit
4e4755aba5
  1. 8
      src/test/java/TestEmojiPicker.java

8
src/test/java/TestEmojiPicker.java

@ -51,21 +51,21 @@ public class TestEmojiPicker {
} }
} }
// Test to ensure each emoji button has an EmojiActionListener attached
@Test @Test
public void testEmojiPickerActionListener() { public void testEmojiPickerActionListener() {
// Arrange
JTextField textField = new JTextField(); JTextField textField = new JTextField();
EmojiPicker emojiPicker = new EmojiPicker(textField); EmojiPicker emojiPicker = new EmojiPicker(textField);
// Act
Component[] components = emojiPicker.getComponents(); Component[] components = emojiPicker.getComponents();
// Assert
for (Component component : components) { for (Component component : components) {
assertTrue(component instanceof JButton); assertTrue(component instanceof JButton);
JButton button = (JButton) component; JButton button = (JButton) component;
assertNotNull(button.getActionListeners()); assertNotNull(button.getActionListeners());
assertEquals(1, button.getActionListeners().length); assertEquals(1, button.getActionListeners().length);
assertTrue(button.getActionListeners()[0] instanceof EmojiPicker.EmojiActionListener); assertTrue(button.getActionListeners()[0] instanceof EmojiPicker.EmojiActionListener);
} }

Loading…
Cancel
Save