1 parent
d0fcc93a8d
commit
5607e97533
7 files changed
+60
-9
No files matched your search
+20
-1
@@ -32,11 +32,30 @@ describe('ListCommentsUseCase', () => {
|
||||
|
||||
const result = await useCase.execute(new ListCommentsQuery(1, 'user-1', 1, 'comment-1'));
|
||||
|
||||
expect(commentRepository.findByIssue).toHaveBeenCalledWith({ issueId: 1, limit: 1, cursor: 'comment-1' });
|
||||
expect(commentRepository.findByIssue).toHaveBeenCalledWith({
|
||||
issueId: 1,
|
||||
limit: 1,
|
||||
cursor: 'comment-1',
|
||||
direction: 'forward',
|
||||
});
|
||||
expect(result.list.map((comment) => comment.id)).toEqual(['comment-2']);
|
||||
expect(result.nextCursor).toBe('comment-2');
|
||||
});
|
||||
|
||||
it('forwards the backward direction for chat-style paging', async () => {
|
||||
vi.mocked(issueRepository.findById).mockResolvedValue(buildIssue());
|
||||
vi.mocked(commentRepository.findByIssue).mockResolvedValue({ list: [], nextCursor: null });
|
||||
|
||||
await useCase.execute(new ListCommentsQuery(1, 'user-1', 20, 'comment-5', 'backward'));
|
||||
|
||||
expect(commentRepository.findByIssue).toHaveBeenCalledWith({
|
||||
issueId: 1,
|
||||
limit: 20,
|
||||
cursor: 'comment-5',
|
||||
direction: 'backward',
|
||||
});
|
||||
});
|
||||
|
||||
it('throws IssueNotFoundException when the issue is not visible to the user', async () => {
|
||||
vi.mocked(issueRepository.findById).mockResolvedValue(null);
|
||||
|
||||
|
||||
Reference in new issue
Block a user