Files
psf-memo/psf-memo-db/test/unit/use-cases/list-following.unit.js
T
Chris Troutner 247d4a9fcf Implement follow-user and follow-read behavior
- Add MemoFollow service for follow/unfollow broadcast with hash160 payloads
- Update Profiles store with follow state
- Extend ProfilePage and Profile UI with Follow/Unfollow buttons
- Add psf-memo-db /follow/state, /follow/following, /follow/followers endpoints
- Add FollowQuery adapter, use cases, REST controller, and unit tests
- Update acceptance handlers for both components

By coder.
2026-08-27 10:35:33 -07:00

46 lines
1.3 KiB
JavaScript

/*
Unit tests for the ListFollowing use case.
*/
import { assert } from 'chai'
import ListFollowing from '../../../src/use-cases/list-following.js'
function makeAdapters (following) {
return {
followQuery: {
async listFollowing (followerAddr) {
return following
}
}
}
}
describe('#ListFollowing', () => {
it('should throw when adapters is missing', () => {
assert.throws(() => new ListFollowing({}), /Adapters required/)
})
it('should throw when followQuery adapter is missing', () => {
assert.throws(() => new ListFollowing({ adapters: {} }), /followQuery adapter required/)
})
it('should return the following list', async () => {
const useCase = new ListFollowing({ adapters: makeAdapters(['bitcoincash:a', 'bitcoincash:b']) })
const result = await useCase.execute({ followerAddr: 'bitcoincash:follower' })
assert.deepEqual(result, {
followerAddr: 'bitcoincash:follower',
following: ['bitcoincash:a', 'bitcoincash:b']
})
})
it('should reject a missing followerAddr', async () => {
const useCase = new ListFollowing({ adapters: makeAdapters([]) })
try {
await useCase.execute({})
assert.fail('expected error')
} catch (err) {
assert.match(err.message, /followerAddr is required/)
}
})
})