Add ApiCacheManager test for should remove recent-episodes cache entries
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Run Component Tests / Run Component Tests (push) Waiting to run
Build and Push Docker Image / build (push) Waiting to run
Integration Test / build and test (push) Waiting to run
Run Unit Tests / Run Unit Tests (push) Waiting to run

This commit is contained in:
advplyr 2026-04-26 16:51:39 -05:00
parent 92df92ec99
commit 62d7097e23

View file

@ -1,6 +1,7 @@
// Import dependencies and modules for testing
const { expect } = require('chai')
const sinon = require('sinon')
const { LRUCache } = require('lru-cache')
const ApiCacheManager = require('../../../server/managers/ApiCacheManager')
describe('ApiCacheManager', () => {
@ -94,4 +95,17 @@ describe('ApiCacheManager', () => {
expect(res.originalSend.calledWith(body)).to.be.true
})
})
describe('clear on mediaProgress', () => {
it('should remove recent-episodes cache entries', () => {
const key = JSON.stringify({ user: 'u', url: '/libraries/abc-123/recent-episodes?limit=50&page=0' })
const cache = new LRUCache({ max: 10 })
cache.set(key, { body: '[]', headers: {}, statusCode: 200 })
const manager = new ApiCacheManager(cache)
manager.clear({ name: 'mediaProgress' }, 'afterUpdate')
expect(cache.get(key)).to.be.undefined
})
})
})