Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

906 B
Raw Blame
import { render, screen } from '@testing-library/react'
import { describe, expect, it } from 'vitest'

import { SelectionListState } from './SelectionListState'

describe('SelectionListState', () => {
  it('keeps one persistent live region while its state changes', () => {
    const { container, rerender } = render(<SelectionListState isLoading />)

    const liveRegion = container.querySelector('[aria-live="polite"]')
    expect(liveRegion).not.toBeNull()
    if (!liveRegion) throw new Error('Expected an aria-live status region')
    expect(liveRegion).toHaveAttribute('aria-live', 'polite')
    expect(liveRegion).toHaveClass('sr-only')
    expect(liveRegion).toHaveTextContent('Loading options')

    rerender(<SelectionListState isEmpty emptyLabel="No columns found" />)

    expect(screen.getByText('No columns found')).toBe(liveRegion)
    expect(liveRegion).not.toHaveClass('sr-only')
  })
})