Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/react-router/tests/link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ describe('Link', () => {
// navigate to /?foo=bar
await act(() => fireEvent.click(indexFooBarLink))

await waitFor(() => {
expect(indexFooBarLink).toHaveClass('active')
})

expect(indexExactLink).toHaveClass('inactive')
expect(indexExactLink).not.toHaveClass('active')
expect(indexExactLink).toHaveAttribute('href', '/')
Expand Down
32 changes: 22 additions & 10 deletions packages/react-router/tests/optional-path-params.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import {
act,
cleanup,
fireEvent,
render,
screen,
waitFor,
} from '@testing-library/react'
import {
Link,
Outlet,
Expand Down Expand Up @@ -639,17 +646,22 @@ describe('React Router - Optional Path Parameters', () => {

// Test navigation scenarios
const navigateAll = await screen.findByTestId('navigate-all')
const navigateTech = await screen.findByTestId('navigate-tech')
const navigateSpecific = await screen.findByTestId('navigate-specific')

fireEvent.click(navigateAll)
expect(router.state.location.pathname).toBe('/posts')
await fireEvent.click(navigateAll)
await waitFor(() => {
expect(router.state.location.pathname).toBe('/posts')
})

fireEvent.click(navigateTech)
expect(router.state.location.pathname).toBe('/posts/tech')
const navigateTech = await screen.findByTestId('navigate-tech')
await fireEvent.click(navigateTech)
await waitFor(() => {
expect(router.state.location.pathname).toBe('/posts/tech')
})

fireEvent.click(navigateSpecific)
expect(router.state.location.pathname).toBe('/posts/tech/hello-world')
const navigateSpecific = await screen.findByTestId('navigate-specific')
await fireEvent.click(navigateSpecific)
await waitFor(() => {
expect(router.state.location.pathname).toBe('/posts/tech/hello-world')
})
})

it('should handle relative navigation with optional parameters', async () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/solid-router/tests/link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ describe('Link', () => {
// navigate to /?foo=bar
fireEvent.click(indexFooBarLink)

await waitFor(() => {
expect(indexFooBarLink).toHaveClass('active')
})

expect(indexExactLink).toHaveClass('inactive')
expect(indexExactLink).not.toHaveClass('active')
expect(indexExactLink).toHaveAttribute('href', '/')
Expand Down
23 changes: 14 additions & 9 deletions packages/solid-router/tests/optional-path-params.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -647,17 +647,22 @@ describe('Solid Router - Optional Path Parameters', () => {

// Test navigation scenarios
const navigateAll = await screen.findByTestId('navigate-all')
const navigateTech = await screen.findByTestId('navigate-tech')
const navigateSpecific = await screen.findByTestId('navigate-specific')

fireEvent.click(navigateAll)
expect(router.state.location.pathname).toBe('/posts')
await fireEvent.click(navigateAll)
await waitFor(() => {
expect(router.state.location.pathname).toBe('/posts')
})

fireEvent.click(navigateTech)
expect(router.state.location.pathname).toBe('/posts/tech')
const navigateTech = await screen.findByTestId('navigate-tech')
await fireEvent.click(navigateTech)
await waitFor(() => {
expect(router.state.location.pathname).toBe('/posts/tech')
})

fireEvent.click(navigateSpecific)
expect(router.state.location.pathname).toBe('/posts/tech/hello-world')
const navigateSpecific = await screen.findByTestId('navigate-specific')
await fireEvent.click(navigateSpecific)
await waitFor(() => {
expect(router.state.location.pathname).toBe('/posts/tech/hello-world')
})
})

it('should handle relative navigation with optional parameters', async () => {
Expand Down
Loading