egregoros compat

This commit is contained in:
Moon.eth
2026-07-29 20:59:52 +09:00
parent 081460c7f6
commit 5b7b4360d2
16 changed files with 713 additions and 137 deletions
+32 -1
View File
@@ -1,6 +1,12 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { ApiClient } from './client'
import { postStatus, updateProfileFields, updatePublicProfile, votePoll } from './endpoints'
import {
fetchNotifications,
postStatus,
updateProfileFields,
updatePublicProfile,
votePoll,
} from './endpoints'
afterEach(() => {
vi.unstubAllGlobals()
@@ -145,3 +151,28 @@ describe('poll endpoints', () => {
})
})
})
describe('fetchNotifications', () => {
it('defensively applies requested types when a server ignores the filter', async () => {
vi.stubGlobal(
'fetch',
vi.fn().mockResolvedValue(
new Response(
JSON.stringify([
{ id: 'favourite-1', type: 'favourite' },
{ id: 'mention-1', type: 'mention' },
]),
{ status: 200, headers: { 'Content-Type': 'application/json' } },
),
),
)
const page = await fetchNotifications(
new ApiClient('egregoros.example', 'token'),
{ limit: 20 },
['favourite'],
)
expect(page.items).toEqual([{ id: 'favourite-1', type: 'favourite' }])
})
})