mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 20:05:06 +03:00
added event chart test
This commit is contained in:
1 parent
2cea914eb7
commit
efc9b64ca4
1 file changed
+26
@@ -0,0 +1,26 @@
|
||||
import LogEventChart from 'components/interfaces/Settings/Logs/LogEventChart'
|
||||
import { render, waitFor, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
|
||||
jest.mock('components/ui/Flag/Flag')
|
||||
import Flag from 'components/ui/Flag/Flag'
|
||||
Flag.mockImplementation(({ children }) => <>{children}</>)
|
||||
jest.mock('hooks')
|
||||
import { useFlag } from 'hooks'
|
||||
useFlag.mockReturnValue(true)
|
||||
|
||||
test('renders bars', async () => {
|
||||
const mockFn = jest.fn()
|
||||
const tsMicro = new Date().getTime() * 1000
|
||||
const { container } = render(
|
||||
<LogEventChart
|
||||
data={[{ timestamp: tsMicro }, { timestamp: { timestamp: tsMicro + 1 } }]}
|
||||
onBarClick={mockFn}
|
||||
/>
|
||||
)
|
||||
// should only have one bar rendered
|
||||
const paths = container.querySelectorAll('path')
|
||||
expect(paths.length).toBe(1)
|
||||
userEvent.click(paths[0])
|
||||
expect(mock).toBeCalledTimes(1)
|
||||
})
|
||||
Reference in new issue
Block a user