fix: update EdgeModal tests for None/Snake/Flow animation selector
This commit is contained in:
@@ -97,26 +97,52 @@ describe('EdgeModal', () => {
|
|||||||
expect(onSubmit.mock.calls[0][0].path_style).toBe('smooth')
|
expect(onSubmit.mock.calls[0][0].path_style).toBe('smooth')
|
||||||
})
|
})
|
||||||
|
|
||||||
// ── Animated toggle ───────────────────────────────────────────────────────
|
// ── Animation select ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
it('flow animation defaults to off', () => {
|
it('animation defaults to None — animated omitted from payload', () => {
|
||||||
const onSubmit = vi.fn()
|
const onSubmit = vi.fn()
|
||||||
render(<EdgeModal open onClose={vi.fn()} onSubmit={onSubmit} />)
|
render(<EdgeModal open onClose={vi.fn()} onSubmit={onSubmit} />)
|
||||||
fireEvent.click(screen.getByRole('button', { name: 'Connect' }))
|
fireEvent.click(screen.getByRole('button', { name: 'Connect' }))
|
||||||
// animated: false → omitted (falsy || undefined)
|
expect(onSubmit.mock.calls[0][0].animated).toBeUndefined()
|
||||||
expect(onSubmit.mock.calls[0][0].animated).toBeFalsy()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('toggling animation sends animated: true', () => {
|
it('selecting Snake sends animated: "snake"', () => {
|
||||||
const onSubmit = vi.fn()
|
const onSubmit = vi.fn()
|
||||||
render(<EdgeModal open onClose={vi.fn()} onSubmit={onSubmit} />)
|
render(<EdgeModal open onClose={vi.fn()} onSubmit={onSubmit} />)
|
||||||
// Find the toggle: it's the only button with aria-pressed attribute
|
fireEvent.click(screen.getByText('Snake'))
|
||||||
const allButtons = screen.getAllByRole('button')
|
|
||||||
const toggle = allButtons.find((b) => b.hasAttribute('aria-pressed'))!
|
|
||||||
expect(toggle).toBeDefined()
|
|
||||||
fireEvent.click(toggle)
|
|
||||||
fireEvent.click(screen.getByRole('button', { name: 'Connect' }))
|
fireEvent.click(screen.getByRole('button', { name: 'Connect' }))
|
||||||
expect(onSubmit.mock.calls[0][0].animated).toBe(true)
|
expect(onSubmit.mock.calls[0][0].animated).toBe('snake')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('selecting Flow sends animated: "flow"', () => {
|
||||||
|
const onSubmit = vi.fn()
|
||||||
|
render(<EdgeModal open onClose={vi.fn()} onSubmit={onSubmit} />)
|
||||||
|
fireEvent.click(screen.getByText('Flow'))
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Connect' }))
|
||||||
|
expect(onSubmit.mock.calls[0][0].animated).toBe('flow')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('selecting None after Snake omits animated from payload', () => {
|
||||||
|
const onSubmit = vi.fn()
|
||||||
|
render(<EdgeModal open onClose={vi.fn()} onSubmit={onSubmit} />)
|
||||||
|
fireEvent.click(screen.getByText('Snake'))
|
||||||
|
fireEvent.click(screen.getByText('None'))
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Connect' }))
|
||||||
|
expect(onSubmit.mock.calls[0][0].animated).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('pre-fills animation from initial "snake" string', () => {
|
||||||
|
const onSubmit = vi.fn()
|
||||||
|
render(<EdgeModal open onClose={vi.fn()} onSubmit={onSubmit} initial={{ animated: 'snake' }} />)
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Connect' }))
|
||||||
|
expect(onSubmit.mock.calls[0][0].animated).toBe('snake')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('pre-fills animation from legacy initial true (backward compat)', () => {
|
||||||
|
const onSubmit = vi.fn()
|
||||||
|
render(<EdgeModal open onClose={vi.fn()} onSubmit={onSubmit} initial={{ animated: true }} />)
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: 'Connect' }))
|
||||||
|
expect(onSubmit.mock.calls[0][0].animated).toBe('snake')
|
||||||
})
|
})
|
||||||
|
|
||||||
// ── Pre-fill ──────────────────────────────────────────────────────────────
|
// ── Pre-fill ──────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user