mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
egregoros compat
This commit is contained in:
@@ -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' }])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user