mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-12 06:21:30 +00:00
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
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:
parent
92df92ec99
commit
62d7097e23
1 changed files with 14 additions and 0 deletions
|
|
@ -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
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue