mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
* fix logs previewer and msw * refactor api mocking for better dx * update readme * comment out error handler for vitest * rm unnecessary tests * fix custom render nuqs type * add logs search test * rm unnecessary import * update readme with customRender and customRednerHook * rm unnecessary api handler * Move the NODE_ENV to the studio build command in turbo.json. * Update apps/studio/tests/README.md Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * add cursor rule --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
32 lines
965 B
TypeScript
32 lines
965 B
TypeScript
import { render, screen, waitFor } from '@testing-library/react'
|
|
import { routerMock } from '../lib/route-mock'
|
|
import { expect, suite, test } from 'vitest'
|
|
import { RouterComponent } from './router'
|
|
|
|
suite('Router Mock', () => {
|
|
test('Router mock works as expected', async () => {
|
|
const comp = render(<RouterComponent />)
|
|
expect(comp.container.textContent).toContain('path: /')
|
|
expect(routerMock.pathname).toBe('/')
|
|
})
|
|
|
|
test('Clicking on link changes the path', async () => {
|
|
const comp = render(<RouterComponent />)
|
|
|
|
const link = screen.getByRole('link')
|
|
|
|
link.click()
|
|
|
|
waitFor(() => {
|
|
expect(routerMock.pathname).toBe('/test')
|
|
expect(comp.container.textContent).toContain('path: /test')
|
|
})
|
|
})
|
|
|
|
test('Router mock is reset after each test', async () => {
|
|
const comp = render(<RouterComponent />)
|
|
expect(comp.container.textContent).toContain('path: /')
|
|
expect(routerMock.pathname).toBe('/')
|
|
})
|
|
})
|