This pull finalizes the user authentication integration tests by adding new test cases for both successful and error scenarios. The tests ensure the robustness of the user registration and login functionalities.
Changes
Test Setup
Connected to MongoDB using mongoose.connect with the database name specified in the environment variables.
Added quizRoutes middleware to the app.
Test Cases for Successful API Handlers
registerUser
Tests successful user registration and verifies the response status.
loginUser
Tests successful user login and verifies the response status.
Test Cases for Error API Handlers
Missing Fields in Registration
Tests registration with missing fields and verifies the response status and error message.
Mismatched Passwords
Tests registration with mismatched passwords and verifies the response status and error message.
User Already Registered
Tests registration with an already registered user and verifies the response status and error message.
Missing Fields in Login
Tests login with missing fields and verifies the response status and error message.
Invalid Credentials
Tests login with invalid credentials and verifies the response status and error message.
Testing
The test suite covers the following scenarios:
Successful user registration and verification of the response.
Successful user login and verification of the response.
Error scenarios for user registration and login, including missing fields, mismatched passwords, already registered user, and invalid credentials.
Additional Information
The changes aim to ensure comprehensive testing of user-related API endpoints, enhancing code reliability and maintainability.
Summary
This pull finalizes the user authentication integration tests by adding new test cases for both successful and error scenarios. The tests ensure the robustness of the user registration and login functionalities.
Changes
Test Setup
mongoose.connect
with the database name specified in the environment variables.quizRoutes
middleware to the app.Test Cases for Successful API Handlers
Test Cases for Error API Handlers
Testing
Additional Information