Browse Source

refactoring: added / removed some comments in LoginGUITest and fixed some indentations

remotes/origin/hotfix/client/improve-chat-window-appearence
Richard Schmidt 11 months ago
parent
commit
33a294efef
  1. 25
      src/test/java/SignUpGUITest.java

25
src/test/java/SignUpGUITest.java

@ -1,4 +1,3 @@
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@ -6,31 +5,29 @@ import org.junit.jupiter.api.BeforeEach;
import java.awt.Component;
import java.awt.event.ActionEvent;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
class SignUpGUITest {
private SignUpGUI signUpGUI;
//Instantiates a new instance of SignUpGUI
@BeforeEach
void setUp() {
signUpGUI = new SignUpGUI();
signUpGUI.setVisible(true);
}
//Disposes of the instance
@AfterEach
void tearDown() {
signUpGUI.dispose();
}
//Tests text field and button inputs
@Test
public void testSignUpButtonActionPerformed() {
// Set up text fields
signUpGUI.getUsernameField().setText("testUser");
signUpGUI.getPasswordField().setText("password");
signUpGUI.getConfirmPasswordField().setText("password");
@ -38,14 +35,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
signUpGUI.getFirstNameField().setText("John");
signUpGUI.getSurnameField().setText("Doe");
// Perform action
ActionEvent actionEvent = new ActionEvent(signUpGUI.getSignUpButton(), ActionEvent.ACTION_PERFORMED, "");
signUpGUI.actionPerformed(actionEvent);
}
//Tests if passwords are mismatched
@Test
void testPasswordMismatch() {
SignUpGUI signUpGUI = new SignUpGUI();
@ -56,12 +50,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
signUpGUI.getFirstNameField().setText("John");
signUpGUI.getSurnameField().setText("Doe");
signUpGUI.getSignUpButton().doClick(); // Simulate button click
signUpGUI.getSignUpButton().doClick();
// Make sure an error message dialog is shown
assertTrue(isErrorMessageShown(signUpGUI));
}
//Tests if user-name already exists
@Test
void testExistingUsername() {
SignUpGUI signUpGUI = new SignUpGUI();
@ -72,9 +66,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
signUpGUI.getFirstNameField().setText("John");
signUpGUI.getSurnameField().setText("Doe");
signUpGUI.getSignUpButton().doClick(); // Simulate button click
signUpGUI.getSignUpButton().doClick();
// Make sure an error message dialog is shown
assertTrue(isErrorMessageShown(signUpGUI));
}
@ -85,9 +78,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
if (component instanceof JOptionPane) {
return false;
}
}
return true;
}
}
Loading…
Cancel
Save