The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
import { act, renderHook } from '@testing-library/react'
import { describe, expect, it } from 'vitest'
import { useTableRowSelection } from './useTableRowSelection'
describe('useTableRowSelection', () => {
it('restores a linked log and resets when filters or project change', () => {
const { result, rerender } = renderHook(
({ scope }) => useTableRowSelection({ scope, initialId: 'b' }),
{ initialProps: { scope: 'project-1:filters-1' } }
)
expect(result.current.selection.selected).toEqual({ b: true })
act(() => result.current.selectRow(['a', 'b', 'c'], 'c', { shiftKey: true }))
expect(result.current.selection.selected).toEqual({ b: true, c: true })
rerender({ scope: 'project-1:filters-1' })
expect(result.current.selection.selected).toEqual({ b: true, c: true })
rerender({ scope: 'project-1:filters-2' })
expect(result.current.selection).toEqual({ selected: {} })
act(() => result.current.selectRow(['a'], 'a'))
rerender({ scope: 'project-2:filters-2' })
expect(result.current.selection).toEqual({ selected: {} })
})
it('clears the anchor and selection when closing the pane', () => {
const { result } = renderHook(() => useTableRowSelection({ scope: 'logs', initialId: 'a' }))
act(() => result.current.clearSelection())
expect(result.current.selection).toEqual({ selected: {} })
})
})