martin-markovic / learn-connect

Multi-feature platform designed to enhance the online learning experience.
MIT License
0 stars 0 forks source link

update user integration test #12

Closed martin-markovic closed 2 months ago

martin-markovic commented 2 months ago

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

  1. Test Setup

    • Connected to MongoDB using mongoose.connect with the database name specified in the environment variables.
    • Added quizRoutes middleware to the app.
  2. 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.
  3. 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

Additional Information