fix(tmdb): address follow-up review — drop TestBed from cache spec, hide sub-services, if-eviction

- tmdb-cache.service.spec.ts instantiates TmdbCacheService directly: the
  services Jest target has no @angular/core/testing, which failed CI
  typechecks (Codex P1); the service has no DI dependencies anyway.
- TmdbPersonService/TmdbRuntimeService/TmdbSeasonService are no longer
  re-exported from the public barrel — they are implementation details of
  the TmdbEnrichmentService facade (greptile P2).
- LRU eviction uses an explicit `if`: delete-then-reinsert means the map
  can only ever be one entry over the cap (greptile P2).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Fable 5 committed 2026-07-04 17:42:33 +02:00
1 parent 1f86ec3342
commit 9e7a18496d
3 files changed
+7 -10

No files matched your search

-3
View File
@@ -6,7 +6,4 @@ export * from './tmdb-episode-merge';
export * from './tmdb-matcher';
export * from './tmdb-merge';
export * from './tmdb-person';
export * from './tmdb-person.service';
export * from './tmdb-runtime.service';
export * from './tmdb-season.service';
export * from './tmdb.types';
@@ -1,4 +1,3 @@
import { TestBed } from '@angular/core/testing';
import { TmdbCacheEntry } from '@iptvnator/shared/interfaces';
import { TmdbCacheService } from './tmdb-cache.service';
@@ -15,8 +14,9 @@ describe('TmdbCacheService (in-memory LRU)', () => {
});
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TmdbCacheService);
// No Angular DI dependencies — instantiate directly (the services
// Jest target has no @angular/core/testing available)
service = new TmdbCacheService();
});
it('stores and returns entries with a fetchedAt stamp', async () => {
@@ -81,12 +81,12 @@ export class TmdbCacheService {
);
this.memoryCache.delete(key);
this.memoryCache.set(key, stamped);
while (this.memoryCache.size > MEMORY_CACHE_MAX_ENTRIES) {
// delete-then-reinsert above means at most one entry over the cap
if (this.memoryCache.size > MEMORY_CACHE_MAX_ENTRIES) {
const oldest = this.memoryCache.keys().next().value;
if (oldest === undefined) {
break;
if (oldest !== undefined) {
this.memoryCache.delete(oldest);
}
this.memoryCache.delete(oldest);
}
}