Skip to content

Commit

Permalink
chore: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
laminne committed Dec 9, 2024
1 parent ae3ec79 commit 0265d93
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/timeline/adaptor/repository/dummy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { afterEach, describe, expect, it } from 'vitest';

import type { AccountID } from '../../../accounts/model/account.js';
import { Note, type NoteID } from '../../../notes/model/note.js';
import { TimelineInvalidFilterRangeError } from '../../model/errors.js';
import { List, type ListID } from '../../model/list.js';
import { InMemoryListRepository, InMemoryTimelineRepository } from './dummy.js';

Expand Down Expand Up @@ -94,7 +95,7 @@ describe('InMemoryTimelineRepository', () => {
* ---------------
* ↓ afterID
* 4, 3, 2, 1
* ←| return 3,2 (4 is filtered out because it is DIRECT note)
* ←| return 3,2 (4 is filtered out because it is DIRECT note)
*/
const actual = await repository.getAccountTimeline('100' as AccountID, {
id: '100' as AccountID,
Expand All @@ -121,6 +122,20 @@ describe('InMemoryTimelineRepository', () => {
expect(Result.unwrap(actual)).toHaveLength(3);
});

it('filter: if after/beforeID both are specified, return error', async () => {
const actual = await repository.getAccountTimeline('100' as AccountID, {
id: '100' as AccountID,
hasAttachment: true,
noNsfw: false,
afterID: '1' as NoteID,
beforeId: '1' as NoteID,
});
expect(Result.isErr(actual)).toBe(true);
expect(Result.unwrapErr(actual)).toBeInstanceOf(
TimelineInvalidFilterRangeError,
);
});

it('Account Timeline only returns PUBLIC/HOME/FOLLOWERS notes', async () => {
const actual = await repository.getAccountTimeline('100' as AccountID, {
id: '100' as AccountID,
Expand Down

0 comments on commit 0265d93

Please sign in to comment.