Browse Source

refactoring:testEmojiPickerActionListener

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

28
src/test/java/TestEmojiPicker.java

@ -51,24 +51,24 @@ 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();
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());
// Act
Component[] components = emojiPicker.getComponents();
assertEquals(1, button.getActionListeners().length);
assertTrue(button.getActionListeners()[0] instanceof EmojiPicker.EmojiActionListener);
}
// 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 @Test

Loading…
Cancel
Save