mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
quote posts
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { render } from '@testing-library/svelte'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { render, waitFor } from '@testing-library/svelte'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { APP_SERVICES } from '$lib/app-services'
|
||||
import { account, session, testServices } from '$test/fixtures'
|
||||
import { account, session, status, testServices } from '$test/fixtures'
|
||||
import Compose from './Compose.svelte'
|
||||
|
||||
describe('Compose route', () => {
|
||||
@@ -22,4 +22,22 @@ describe('Compose route', () => {
|
||||
expect(view.getByRole('textbox', { name: 'Entry text' })).toHaveValue('@bob@example.test ')
|
||||
expect(view.getByRole('combobox', { name: 'Who can see this' })).toHaveValue('direct')
|
||||
})
|
||||
|
||||
it('loads and previews a quote target without a backend', async () => {
|
||||
const fetchStatus = vi.fn().mockResolvedValue(
|
||||
status({ id: 'quoted-entry', content: '<p>Loaded quote target</p>' }),
|
||||
)
|
||||
const services = testServices({
|
||||
session: session({ token: 'token', me: account(), signedIn: true }),
|
||||
endpoints: { fetchStatus },
|
||||
})
|
||||
const view = render(Compose, {
|
||||
props: { quoteId: 'quoted-entry' },
|
||||
context: new Map([[APP_SERVICES, services]]),
|
||||
})
|
||||
|
||||
await waitFor(() => expect(fetchStatus).toHaveBeenCalledOnce())
|
||||
expect(await view.findByText('Loaded quote target')).toBeInTheDocument()
|
||||
expect(view.getByRole('button', { name: 'Post Quote' })).toBeEnabled()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user