From b9c25369c7fd2acf24af132eeda676e440563203 Mon Sep 17 00:00:00 2001
From: TO
Date: Sun, 9 Nov 2025 00:00:36 +0100
Subject: [PATCH] prettier
---
TESTING.md | 16 ++
TEST_COVERAGE.md | 17 ++
.../champion-randomizer.component.css | 2 +-
.../champion-randomizer.component.html | 24 +-
.../champion-randomizer.component.spec.ts | 10 +-
.../champion-randomizer.component.ts | 10 +-
.../control-header.component.html | 24 +-
.../lane-card/lane-card.component.css | 3 +-
.../lane-card/lane-card.component.html | 208 +++++++++---------
.../directives/preload-link.directive.spec.ts | 8 +-
.../image-cache.interceptor.spec.ts | 2 +-
.../services/champion-data.service.spec.ts | 2 +-
src/app/services/champion-data.service.ts | 6 +-
.../services/image-preload.service.spec.ts | 2 +-
src/app/services/random-number.spec.ts | 2 +-
15 files changed, 189 insertions(+), 147 deletions(-)
diff --git a/TESTING.md b/TESTING.md
index 8297bb7..8117577 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -3,6 +3,7 @@
## Quick Start
Run all tests:
+
```bash
npm test
```
@@ -31,25 +32,30 @@ src/app/
## What's Tested
### Components (4)
+
- ✅ **App** - Main application component
- ✅ **ChampionRandomizerComponent** - Core randomization logic
- ✅ **ControlHeaderComponent** - User controls
- ✅ **LaneCardComponent** - Individual lane display
### Services (3)
+
- ✅ **ChampionDataService** - Data fetching and caching
- ✅ **ImagePreloadService** - Image preloading
- ✅ **RandomNumber** - Secure random generation
### Directives (1)
+
- ✅ **PreloadLinkDirective** - Link preloading
### Interceptors (1)
+
- ✅ **imageCacheInterceptor** - HTTP caching
## Key Test Scenarios
### Champion Randomizer
+
- Random champion assignment for each lane
- Lane enable/disable functionality
- Reroll system with bank management
@@ -58,6 +64,7 @@ src/app/
- Copy draft to clipboard
### Champion Data Service
+
- API data fetching
- LocalStorage caching (24-hour expiry)
- Cache validation and invalidation
@@ -65,11 +72,13 @@ src/app/
- Champion filtering and sorting
### Random Number Service
+
- Cryptographically secure random numbers
- Range validation
- Edge case handling
### Image Management
+
- Cache control headers
- Image preloading
- Duplicate prevention
@@ -78,6 +87,7 @@ src/app/
## Test Configuration
The project uses:
+
- **Framework**: Jasmine
- **Runner**: Karma
- **Browser**: Chrome (or ChromeHeadless for CI)
@@ -85,6 +95,7 @@ The project uses:
## Continuous Integration
For CI environments without a display:
+
```bash
npm test -- --watch=false --browsers=ChromeHeadless
```
@@ -92,6 +103,7 @@ npm test -- --watch=false --browsers=ChromeHeadless
## Code Coverage
Generate coverage report:
+
```bash
ng test --no-watch --code-coverage
```
@@ -110,20 +122,24 @@ Coverage report will be available in `coverage/` directory.
## Troubleshooting
### Tests won't run
+
- Ensure all dependencies are installed: `npm install`
- Check that Chrome is installed for Karma
### Specific test failing
+
- Run tests in watch mode: `npm test`
- Check console output for specific error messages
### Coverage not generating
+
- Ensure you're using the `--code-coverage` flag
- Check that all test files end with `.spec.ts`
## Contributing
When adding new features:
+
1. Write tests first (TDD approach)
2. Ensure all tests pass
3. Maintain high code coverage
diff --git a/TEST_COVERAGE.md b/TEST_COVERAGE.md
index 8580ec5..8bc792a 100644
--- a/TEST_COVERAGE.md
+++ b/TEST_COVERAGE.md
@@ -5,12 +5,14 @@ This document provides an overview of all the tests created for the Random LOL a
## Test Files Created/Updated
### 1. **App Component Tests** (`src/app/app.spec.ts`)
+
- ✅ Component creation
- ✅ ImagePreloadService injection
- ✅ Champion randomizer component rendering
- ✅ Toolbar rendering
### 2. **Champion Randomizer Component Tests** (`src/app/components/champion-randomizer.component.spec.ts`)
+
- ✅ Component creation and initialization
- ✅ Lane management (enable/disable lanes)
- ✅ Champion assignment and rolling
@@ -26,6 +28,7 @@ This document provides an overview of all the tests created for the Random LOL a
- ✅ Shift key tracking for force rerolls
### 3. **Control Header Component Tests** (`src/app/components/control-header/control-header.component.spec.ts`)
+
- ✅ Component creation
- ✅ All input properties (isLoading, hasChampions, loadError, canCopyDraft, rerollBank, rerollBankMax)
- ✅ Output events (roll, retry, copyDraft)
@@ -33,6 +36,7 @@ This document provides an overview of all the tests created for the Random LOL a
- ✅ Template rendering (spinner, error messages)
### 4. **Lane Card Component Tests** (`src/app/components/lane-card/lane-card.component.spec.ts`)
+
- ✅ Component creation
- ✅ All input properties (lane, laneLabel, champion, canReRoll, isLoading, hasChampions, isShiftPressed, disabled)
- ✅ Output events (changeChampion, toggleDisableLane)
@@ -40,6 +44,7 @@ This document provides an overview of all the tests created for the Random LOL a
- ✅ Template rendering (champion name, image, lane label, role chips, disabled styling)
### 5. **Champion Data Service Tests** (`src/app/services/champion-data.service.spec.ts`)
+
- ✅ Service creation
- ✅ Loading champions from API
- ✅ HTTP to HTTPS URL conversion
@@ -58,11 +63,13 @@ This document provides an overview of all the tests created for the Random LOL a
- ✅ Invalid cache data handling
### 6. **Image Preload Service Tests** (`src/app/services/image-preload.service.spec.ts`)
+
- ✅ Service creation
- ✅ Cache clearing functionality
- ✅ Error handling during cache operations
### 7. **Random Number Service Tests** (`src/app/services/random-number.spec.ts`)
+
- ✅ Service creation
- ✅ Random number generation within range
- ✅ Edge case: max = 1
@@ -73,12 +80,14 @@ This document provides an overview of all the tests created for the Random LOL a
- ✅ crypto.getRandomValues usage verification
### 8. **Preload Link Directive Tests** (`src/app/directives/preload-link.directive.spec.ts`)
+
- ✅ Directive creation
- ✅ Preload link addition to document head
- ✅ Fetchpriority attribute setting
- ✅ Duplicate link prevention
### 9. **Image Cache Interceptor Tests** (`src/app/interceptors/image-cache.interceptor.spec.ts`)
+
- ✅ Cache header addition for PNG images
- ✅ Cache header addition for JPG images
- ✅ Cache header addition for JPEG images
@@ -93,6 +102,7 @@ This document provides an overview of all the tests created for the Random LOL a
## Test Statistics
### Total Test Suites: 9
+
- App: 4 tests
- Champion Randomizer: 29 tests
- Control Header: 10 tests
@@ -108,20 +118,24 @@ This document provides an overview of all the tests created for the Random LOL a
## Coverage Areas
### ✅ Components (100%)
+
- App
- ChampionRandomizerComponent
- ControlHeaderComponent
- LaneCardComponent
### ✅ Services (100%)
+
- ChampionDataService
- ImagePreloadService
- RandomNumber
### ✅ Directives (100%)
+
- PreloadLinkDirective
### ✅ Interceptors (100%)
+
- imageCacheInterceptor
## Key Testing Features
@@ -138,16 +152,19 @@ This document provides an overview of all the tests created for the Random LOL a
## Running the Tests
To run all tests:
+
```bash
npm test
```
To run tests in headless mode (requires Chrome):
+
```bash
npm test -- --watch=false --browsers=ChromeHeadless
```
To run tests with coverage:
+
```bash
ng test --no-watch --code-coverage
```
diff --git a/src/app/components/champion-randomizer.component.css b/src/app/components/champion-randomizer.component.css
index e5d48b3..8965c40 100644
--- a/src/app/components/champion-randomizer.component.css
+++ b/src/app/components/champion-randomizer.component.css
@@ -23,4 +23,4 @@
.warning-card mat-icon {
font-size: 1.25rem;
-}
\ No newline at end of file
+}
diff --git a/src/app/components/champion-randomizer.component.html b/src/app/components/champion-randomizer.component.html
index 43bc5cc..f4465bd 100644
--- a/src/app/components/champion-randomizer.component.html
+++ b/src/app/components/champion-randomizer.component.html
@@ -12,18 +12,18 @@
>