Files
psf-memo/psf-memo-db/test/unit/use-cases/lib/use-case.unit.js
T
Chris Troutner 30c0949d3f Harden and review post-heights-index refactor
Architectural review of the refactorer's postHeights index work. Extract a
shared assemblePostPage helper and a ListUseCase base class to remove DRY
duplication in the post-list use cases. Build the gherkin-mutator runner
adapter for psf-memo-db and psf-memo-indexer. Add boundary and tie-break
tests to kill all surviving language mutations across the changed files
(post-query, pagination, list use cases, indexer post handler).

Mutation: all changed source files fully killed. DRY: clean. CRAP <= 6.
Soft Gherkin acceptance mutation documented survivors (see review report).

By architect.
2026-08-26 11:39:12 -07:00

40 lines
1.2 KiB
JavaScript

import { assert } from 'chai'
import { ListUseCase } from '../../../../src/use-cases/lib/use-case.js'
class DummyUseCase extends ListUseCase {
constructor (localConfig = {}) {
super(localConfig, { useCaseName: 'DummyUseCase', adapterName: 'postQuery' })
}
async execute (inObj = {}) {
return inObj
}
}
describe('#ListUseCase', () => {
it('should throw when adapters is missing', () => {
try {
new DummyUseCase({})
assert.fail('Expected error')
} catch (err) {
assert.include(err.message, 'Adapters required when instantiating DummyUseCase use case.')
}
})
it('should throw when the required adapter is missing', () => {
try {
new DummyUseCase({ adapters: {} })
assert.fail('Expected error')
} catch (err) {
assert.include(err.message, 'postQuery adapter required for DummyUseCase use case.')
}
})
it('should bind execute to the instance', () => {
const uut = new DummyUseCase({ adapters: { postQuery: {} } })
assert.equal(typeof uut.execute, 'function')
const bound = uut.execute
return bound({ ok: true }).then((result) => assert.deepEqual(result, { ok: true }))
})
})