mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-08 02:11:35 +00:00
test: define large-library browse strategy contract
This commit is contained in:
parent
da490605b7
commit
1533d4146a
4 changed files with 241 additions and 0 deletions
29
test/server/utils/libraryBrowseCount.test.js
Normal file
29
test/server/utils/libraryBrowseCount.test.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
const chai = require('chai')
|
||||
const expect = chai.expect
|
||||
|
||||
const { loadBrowseCount } = require('../../../server/utils/queries/libraryBrowseCount')
|
||||
|
||||
describe('libraryBrowseCount', () => {
|
||||
it('returns deferred exact count metadata on first chunk', async () => {
|
||||
const payload = await loadBrowseCount({
|
||||
mode: 'deferred-exact',
|
||||
exactCountLoader: async () => 123
|
||||
})
|
||||
|
||||
expect(payload).to.deep.equal({ total: 123, isExact: true, isDeferred: true })
|
||||
})
|
||||
|
||||
it('skips exact count work on follow-up endless-scroll chunks', async () => {
|
||||
let called = false
|
||||
const payload = await loadBrowseCount({
|
||||
mode: 'skip',
|
||||
exactCountLoader: async () => {
|
||||
called = true
|
||||
return 123
|
||||
}
|
||||
})
|
||||
|
||||
expect(payload).to.deep.equal({ total: null, isExact: false, isDeferred: true })
|
||||
expect(called).to.equal(false)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue