Browse Source

test_StayLoggedIn button

remotes/origin/server
Richard Schmidt 11 months ago
parent
commit
f4f5a66b3f
  1. 34
      src/test/java/CreateUserTest.java

34
src/test/java/CreateUserTest.java

@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
class CreateUserTest { class CreateUserTest {
@ -58,7 +59,38 @@ class CreateUserTest {
// Clean up - delete the test file after the test // Clean up - delete the test file after the test
File file = new File(filename); File file = new File(filename);
file.delete(); file.delete();
}
@Test
public void testUpdateStayLoggedIn() {
String filename = "test_users.json";
String id = "3";
String userName = "testUser3";
String password = "password789";
String birthday = "2002-01-01";
String firstName = "Jack";
String surname = "Doe";
// Create a user
CreateUser user = new CreateUser(id, userName, password, birthday, firstName, surname);
// Save user to JSON file
user.saveToJsonFile(filename);
// Update stayLoggedIn flag
CreateUser.updateStayLoggedIn(filename, userName, true);
// Read updated user from JSON file
List<CreateUser> userList = CreateUser.readUserListFromJsonFile(filename);
// Ensure that the stayLoggedIn flag is updated
assertTrue(userList.get(0).isStayLoggedIn());
// Clean up - delete the test file after the test
File file = new File(filename);
file.delete();
}
} }
}
Loading…
Cancel
Save