improved component composition and added tests.

This commit is contained in:
Moon.eth
2026-07-29 10:30:28 +09:00
parent 95f9d73681
commit 264ae17a8d
39 changed files with 1811 additions and 147 deletions
+25
View File
@@ -0,0 +1,25 @@
import { render } from '@testing-library/svelte'
import { describe, expect, it } from 'vitest'
import { APP_SERVICES } from '$lib/app-services'
import { account, session, testServices } from '$test/fixtures'
import Compose from './Compose.svelte'
describe('Compose route', () => {
it('resets addressing and defaults to direct when the recipient changes', async () => {
const services = testServices({
session: session({ token: 'token', me: account(), signedIn: true }),
})
const view = render(Compose, {
props: { to: 'alice@example.test' },
context: new Map([[APP_SERVICES, services]]),
})
expect(view.getByRole('textbox', { name: 'Entry text' })).toHaveValue('@alice@example.test ')
expect(view.getByRole('combobox', { name: 'Who can see this' })).toHaveValue('direct')
await view.rerender({ to: 'bob@example.test' })
expect(view.getByRole('textbox', { name: 'Entry text' })).toHaveValue('@bob@example.test ')
expect(view.getByRole('combobox', { name: 'Who can see this' })).toHaveValue('direct')
})
})