martin-markovic / learn-connect

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

Update Test Scripts and Implement Comprehensive Unit and Integration Tests #17

Closed martin-markovic closed 2 months ago

martin-markovic commented 2 months ago

Summary

This pull request includes updates to test scripts and the implementation of comprehensive unit and integration tests for CRUD functions and authentication services. It also includes mock implementations to simulate API responses and local storage behavior.

Changes

  1. Package Installation

    • Installed necessary packages: axios, nock, and node-localstorage.
  2. Script Updates

    • Updated test:unit and test:integration scripts' paths to match the new test file structure.
  3. Unit and Integration Tests

    • Implemented tests for CRUD functions by utilizing nock to mock API responses and verify correct service functionality in quizService.test.js.
    • Implemented error handling expected behavior for CRUD functions in quizService.test.js.
    • Added scratch/user file with sample user data, including token and username for testing purposes.
    • Implemented mock localStorage and mock axios methods to simulate API responses and storage behavior in authService.test.js.
    • Implemented correct user data storage and retrieval from localStorage for auth service functions in authService.test.js.
    • Implemented handling network errors in registerUser and loginUser tests using nock.
    • Defined userData in tests where it was previously undefined.
    • Updated the test cases to use inline user data objects and fixed related issues.

Testing

Additional Information