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