mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
more targeted refresh
This commit is contained in:
@@ -2,6 +2,7 @@ import { act, render, waitFor } from '@testing-library/svelte'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { APP_SERVICES } from '$lib/app-services'
|
||||
import type { Account } from '$lib/api/types'
|
||||
import { TIMELINE_REFRESH, TimelineRefreshController } from '$lib/timeline-refresh'
|
||||
import { account, deferred, session, status, testServices, theme } from '$test/fixtures'
|
||||
import Profile from './Profile.svelte'
|
||||
|
||||
@@ -139,4 +140,31 @@ describe('Profile', () => {
|
||||
expect(view.queryByText('A movie')).not.toBeInTheDocument()
|
||||
expect(view.queryByText('A reposted picture')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('refreshes only the entry feed without reloading the profile', async () => {
|
||||
const lookupAccount = vi.fn().mockResolvedValue(account())
|
||||
const fetchAccountStatuses = vi.fn().mockResolvedValue({
|
||||
items: [status({ content: '<p>Timeline note</p>' })],
|
||||
links: {},
|
||||
})
|
||||
const services = testServices({
|
||||
session: session(),
|
||||
theme: theme(),
|
||||
endpoints: { lookupAccount, fetchAccountStatuses },
|
||||
})
|
||||
const refresh = new TimelineRefreshController()
|
||||
const context = new Map()
|
||||
context.set(APP_SERVICES, services)
|
||||
context.set(TIMELINE_REFRESH, refresh)
|
||||
const view = render(Profile, {
|
||||
props: { acct: 'alice', view: 'blog' },
|
||||
context,
|
||||
})
|
||||
|
||||
expect(await view.findByText('Timeline note')).toBeInTheDocument()
|
||||
expect(refresh.refresh()).toBe(true)
|
||||
|
||||
await waitFor(() => expect(fetchAccountStatuses).toHaveBeenCalledTimes(2))
|
||||
expect(lookupAccount).toHaveBeenCalledOnce()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user