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
Package Installation
Installed necessary packages: axios, nock, and node-localstorage.
Script Updates
Updated test:unit and test:integration scripts' paths to match the new test file structure.
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
Verified the correct installation of axios, nock, and node-localstorage packages.
Ensured the updated paths for test:unit and test:integration scripts are accurate and functional.
Tested CRUD functions in quizService.test.js to confirm proper API response handling and error management.
Validated the mock localStorage and axios methods in authService.test.js to ensure correct simulation of API responses and storage behavior.
Confirmed that user data is correctly stored and retrieved in auth service tests.
Tested network error handling in registerUser and loginUser functions using nock.
Additional Information
These changes improve the reliability and robustness of the test suite by ensuring comprehensive coverage of CRUD operations and authentication processes.
The use of nock and mock implementations provides a reliable testing environment for simulating real-world scenarios.
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
Package Installation
axios
,nock
, andnode-localstorage
.Script Updates
test:unit
andtest:integration
scripts' paths to match the new test file structure.Unit and Integration Tests
nock
to mock API responses and verify correct service functionality inquizService.test.js
.quizService.test.js
.scratch/user
file with sample user data, including token and username for testing purposes.localStorage
and mockaxios
methods to simulate API responses and storage behavior inauthService.test.js
.localStorage
for auth service functions inauthService.test.js
.registerUser
andloginUser
tests usingnock
.userData
in tests where it was previously undefined.Testing
axios
,nock
, andnode-localstorage
packages.test:unit
andtest:integration
scripts are accurate and functional.quizService.test.js
to confirm proper API response handling and error management.localStorage
andaxios
methods inauthService.test.js
to ensure correct simulation of API responses and storage behavior.registerUser
andloginUser
functions usingnock
.Additional Information
nock
and mock implementations provides a reliable testing environment for simulating real-world scenarios.