mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-06-15 23:43:06 +03:00
🗝️ chore: Use Element Access over any-Casts in Registry Cache Spec (#13664)
The as-any casts existed only to reach the protected Keyv cache and private localSnapshotExpiry members. TypeScript's element-access escape hatch provides the same access fully typed, so the casts and their eslint-disable directives are unnecessary. The directives also reported as unused under configs that relax no-explicit-any for test files.
This commit is contained in:
@@ -254,8 +254,7 @@ describe('ServerConfigsCacheRedisAggregateKey Integration Tests', () => {
|
||||
await cache.getAll();
|
||||
|
||||
// Spy on the underlying Keyv cache to count Redis calls
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const cacheGetSpy = jest.spyOn((cache as any).cache, 'get');
|
||||
const cacheGetSpy = jest.spyOn(cache['cache'], 'get');
|
||||
|
||||
await cache.getAll();
|
||||
await cache.getAll();
|
||||
@@ -325,11 +324,9 @@ describe('ServerConfigsCacheRedisAggregateKey Integration Tests', () => {
|
||||
await cache.getAll(); // prime snapshot
|
||||
|
||||
// Force-expire the snapshot without sleeping
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(cache as any).localSnapshotExpiry = Date.now() - 1;
|
||||
cache['localSnapshotExpiry'] = Date.now() - 1;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const cacheGetSpy = jest.spyOn((cache as any).cache, 'get');
|
||||
const cacheGetSpy = jest.spyOn(cache['cache'], 'get');
|
||||
const result = await cache.getAll();
|
||||
expect(cacheGetSpy.mock.calls).toHaveLength(1);
|
||||
expect(Object.keys(result).length).toBe(1);
|
||||
|
||||
Reference in New Issue
Block a user