test: define large-library browse strategy contract

This commit is contained in:
Jonathan Finley 2026-03-13 21:10:47 -04:00
parent da490605b7
commit 1533d4146a
4 changed files with 241 additions and 0 deletions

View 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)
})
})