Files
supabase/apps/studio/tests/pages/projects/LogEventChart.test.tsx
Ivan Vasilov cb1e3a8170 chore: Prep work for pnpm (#29610)
* Add all missing libraries in the packages/apps.

* Add all missing Vitest imports to the tests.

* Add some missing exports to ui.

* Fix the admonition export.

* Fix various minor bugs.

* Migrate the ui package to use vitest.
2024-10-01 11:29:37 +02:00

36 lines
877 B
TypeScript

import { afterEach, beforeEach, test, vi } from 'vitest'
import { screen } from '@testing-library/react'
import LogEventChart from 'components/interfaces/Settings/Logs/LogEventChart'
import { render } from '../../helpers'
const { ResizeObserver } = window
beforeEach(() => {
delete (window as any).ResizeObserver
window.ResizeObserver = vi.fn().mockImplementation(() => ({
observe: vi.fn(),
unobserve: vi.fn(),
disconnect: vi.fn(),
}))
})
afterEach(() => {
window.ResizeObserver = ResizeObserver
})
test('renders chart', async () => {
const mockFn = vi.fn()
const tsMicro = new Date().getTime() * 1000
render(
<LogEventChart
data={[
{ timestamp: tsMicro.toString(), count: 1 },
{ timestamp: (tsMicro + 1).toString(), count: 2 },
]}
onBarClick={mockFn}
/>
)
await screen.findByText(/Logs \/ Time/)
})