mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-06-05 10:12:44 +02:00
Add ApiCacheManager test for should remove recent-episodes cache entries
This commit is contained in:
@@ -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
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user