### Enhance Unit Tests with Mocks and Dependency Injection Updates#62
Merged
Conversation
- Added testing utilities to multiple component and service tests: - Integrated `provideHttpClient` and `provideHttpClientTesting` in `weather`, `dock`, and `finder-app` component tests to enable HTTP testing capabilities. - Added `RouterTestingModule` to `projects-overview.component.spec` for router-related tests. - Mocked dependencies with Jasmine spies in unit tests for `auth.service`, `home-terminal-window.component`, and `cli-game.component`. - Refactored `auth.service` to gracefully handle the absence of Firebase services by making `Auth` injection optional and introducing fallback behaviors. - Wrapped Firebase Firestore and Storage calls in helper methods within `firestore.service` to improve testability and maintain runtime behavior consistency. - Enhanced `firestore.service` to handle optional Firestore injection and replaced direct Firestore method calls with wrapper functions, enabling streamlined mocking for tests. - Made `realtime-db.service` initialization conditional to allow null-safe usage. These changes improve test reliability, maintainability, and resilience, enabling easier mocking and dependency injection for unit testing. Signed-off-by: Colin Michaels <colin@colinmichaels.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



provideHttpClientandprovideHttpClientTestinginweather,dock, andfinder-appcomponent tests to enable HTTP testing capabilities.RouterTestingModuletoprojects-overview.component.specfor router-related tests.auth.service,home-terminal-window.component, andcli-game.component.auth.serviceto gracefully handle the absence of Firebase services by makingAuthinjection optional and introducing fallback behaviors.firestore.serviceto improve testability and maintain runtime behavior consistency.firestore.serviceto handle optional Firestore injection and replaced direct Firestore method calls with wrapper functions, enabling streamlined mocking for tests.realtime-db.serviceinitialization conditional to allow null-safe usage.These changes improve test reliability, maintainability, and resilience, enabling easier mocking and dependency injection for unit testing.