mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo.git
synced 2026-09-21 16:52:01 -07:00
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.
40 lines
1.2 KiB
JavaScript
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 }))
|
|
})
|
|
})
|