mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 03:45:06 +03:00
added failing assertions for router query params updating
This commit is contained in:
1 parent
c36d7e0fa0
commit
90331fef90
1 file changed
+24
-4
@@ -15,7 +15,10 @@ observer.mockImplementation((v) => v)
|
||||
// mock the router
|
||||
jest.mock('next/router')
|
||||
import { useRouter } from 'next/router'
|
||||
useRouter.mockReturnValue({ query: { ref: '123', type: 'auth' } })
|
||||
const router = jest.fn()
|
||||
router.query = { ref: '123', type: 'auth' }
|
||||
router.push = jest.fn()
|
||||
useRouter.mockReturnValue(router)
|
||||
|
||||
// mock monaco editor
|
||||
jest.mock('@monaco-editor/react')
|
||||
@@ -128,6 +131,16 @@ test('Search will trigger a log refresh', async () => {
|
||||
() => {
|
||||
expect(get).toHaveBeenCalledWith(expect.stringContaining('search_query'))
|
||||
expect(get).toHaveBeenCalledWith(expect.stringContaining('something'))
|
||||
|
||||
// updates router query params
|
||||
expect(router.push).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
pathname: expect.any(String),
|
||||
query: expect.objectContaining({
|
||||
s: expect.stringContaining('something'),
|
||||
}),
|
||||
})
|
||||
)
|
||||
},
|
||||
{ timeout: 1500 }
|
||||
)
|
||||
@@ -195,6 +208,16 @@ test('where clause will trigger a log refresh', async () => {
|
||||
() => {
|
||||
expect(get).toHaveBeenCalledWith(expect.stringContaining('where'))
|
||||
expect(get).toHaveBeenCalledWith(expect.stringContaining('metadata.field'))
|
||||
|
||||
// updates router query params
|
||||
expect(router.push).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
pathname: expect.any(String),
|
||||
query: expect.objectContaining({
|
||||
q: expect.stringContaining('something'),
|
||||
}),
|
||||
})
|
||||
)
|
||||
},
|
||||
{ timeout: 1000 }
|
||||
)
|
||||
@@ -202,7 +225,6 @@ test('where clause will trigger a log refresh', async () => {
|
||||
await waitFor(() => screen.getByText(/happened/))
|
||||
})
|
||||
|
||||
|
||||
test('s= query param will populate the search bar', async () => {
|
||||
useRouter.mockReturnValue({
|
||||
query: { ref: '123', type: 'api', s: 'someSearch' },
|
||||
@@ -213,7 +235,6 @@ test('s= query param will populate the search bar', async () => {
|
||||
await waitFor(() => {
|
||||
expect(get).toHaveBeenCalledWith(expect.stringContaining('search_query=someSearch'))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
test('q= query param will populate the query input', async () => {
|
||||
@@ -239,7 +260,6 @@ test('ts= query param will set the timestamp_start param', async () => {
|
||||
await waitFor(() => {
|
||||
expect(get).toHaveBeenCalledWith(expect.stringContaining('timestamp_start=123456'))
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
test('load older btn will fetch older logs', async () => {
|
||||
|
||||
Reference in new issue
Block a user