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