(opts: { explicitUndefined: boolean | undefined })
| 231 | |
| 232 | describe('when the current route has a search fields with undefined values', () => { |
| 233 | async function runTest(opts: { explicitUndefined: boolean | undefined }) { |
| 234 | const rootRoute = createRootRoute() |
| 235 | const indexRoute = createRoute({ |
| 236 | getParentRoute: () => rootRoute, |
| 237 | path: '/', |
| 238 | component: () => { |
| 239 | return ( |
| 240 | <> |
| 241 | <h1>Index</h1> |
| 242 | <Link |
| 243 | to="/" |
| 244 | activeOptions={{ exact: true }} |
| 245 | inactiveProps={{ className: 'inactive' }} |
| 246 | > |
| 247 | Index exact |
| 248 | </Link> |
| 249 | <Link |
| 250 | to="/" |
| 251 | search={{ foo: undefined }} |
| 252 | inactiveProps={{ className: 'inactive' }} |
| 253 | activeOptions={{ explicitUndefined: opts.explicitUndefined }} |
| 254 | > |
| 255 | Index foo=undefined |
| 256 | </Link> |
| 257 | <Link |
| 258 | to="/" |
| 259 | search={{ foo: undefined }} |
| 260 | activeOptions={{ |
| 261 | exact: true, |
| 262 | explicitUndefined: opts.explicitUndefined, |
| 263 | }} |
| 264 | inactiveProps={{ className: 'inactive' }} |
| 265 | > |
| 266 | Index foo=undefined-exact |
| 267 | </Link> |
| 268 | <Link |
| 269 | to="/" |
| 270 | search={{ foo: 'bar' }} |
| 271 | inactiveProps={{ |
| 272 | className: 'inactive', |
| 273 | }} |
| 274 | > |
| 275 | Index foo=bar |
| 276 | </Link> |
| 277 | </> |
| 278 | ) |
| 279 | }, |
| 280 | }) |
| 281 | |
| 282 | const router = createRouter({ |
| 283 | routeTree: rootRoute.addChildren([indexRoute]), |
| 284 | history, |
| 285 | }) |
| 286 | |
| 287 | render(<RouterProvider router={router} />) |
| 288 | |
| 289 | // round 1 |
| 290 | const indexExactLink = await screen.findByRole('link', { |
no test coverage detected