martin-markovic / learn-connect

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

feat Implement user routes unit test #11

Closed martin-markovic closed 2 months ago

martin-markovic commented 2 months ago

PR Description

Summary

This pull request introduces several enhancements and fixes across various modules to improve server handling, response clarity, error handling, and integration of controllers with API endpoints.

Changes

  1. quizUnit.test.js

    • Added after code block to close the server after tests are completed.
    • Imported createMockServer, testDB, and mockUserRoutes for setting up the mock server and routes.
    • Defined existingUser from the test database and a newUser object for testing purposes.
    • registerUser: Tests user registration and verifies the responses to ensure the user is correctly registered with the expected properties.
    • loginUser: Tests user login and verifies the responses to ensure the user is correctly logged in with the expected properties.
    • Implemented expected error handling behavior in test cases.
  2. mockUserController.js

    • Implemented response and error handling in authentication functions.
    • Updated response message in registerUser function for improved clarity.
  3. mockUserRoutes.js

    • Integrated controller functions into their respective API endpoints.

Testing

Additional Information