@@ -316,4 +316,154 @@ mod tests {
316
316
] ,
317
317
)
318
318
}
319
+
320
+ #[ test]
321
+ fn unsupported_template_literal_path ( ) {
322
+ let module_ast = Input :: Code (
323
+ r#"
324
+ const A = "A";
325
+ const B = "B";
326
+ const C = "C";
327
+
328
+ export default {
329
+ 'foo': {
330
+ path: `${prefix}/route/path`,
331
+ layouts: [A, B],
332
+ page: C
333
+ },
334
+ };
335
+ "# ,
336
+ )
337
+ . get_module_ast ( )
338
+ . unwrap ( ) ;
339
+ let symbol_dependency = collect_symbol_dependency ( & module_ast, MOCK_MODULE_PATH ) . unwrap ( ) ;
340
+ let mut symbol_to_routes = SymbolToRoutes :: new ( ) ;
341
+ symbol_to_routes
342
+ . collect_route_dependency ( & module_ast, & symbol_dependency)
343
+ . unwrap ( ) ;
344
+
345
+ assert ! ( symbol_to_routes
346
+ . table
347
+ . get( MOCK_MODULE_PATH )
348
+ . unwrap( )
349
+ . is_empty( ) ) ;
350
+ }
351
+
352
+ #[ test]
353
+ fn unsupported_react_router ( ) {
354
+ let module_ast = Input :: Code (
355
+ // Copied from https://github.com/remix-run/react-router/blob/dev/examples/basic/src/App.tsx
356
+ r#"
357
+ import { Routes, Route, Outlet, Link } from "react-router-dom";
358
+
359
+ export default function App() {
360
+ return (
361
+ <div>
362
+ <h1>Basic Example</h1>
363
+
364
+ <p>
365
+ This example demonstrates some of the core features of React Router
366
+ including nested <code><Route></code>s,{" "}
367
+ <code><Outlet></code>s, <code><Link></code>s, and using a
368
+ "*" route (aka "splat route") to render a "not found" page when someone
369
+ visits an unrecognized URL.
370
+ </p>
371
+
372
+ {/* Routes nest inside one another. Nested route paths build upon
373
+ parent route paths, and nested route elements render inside
374
+ parent route elements. See the note about <Outlet> below. */}
375
+ <Routes>
376
+ <Route path="/" element={<Layout />}>
377
+ <Route index element={<Home />} />
378
+ <Route path="about" element={<About />} />
379
+ <Route path="dashboard" element={<Dashboard />} />
380
+
381
+ {/* Using path="*"" means "match anything", so this route
382
+ acts like a catch-all for URLs that we don't have explicit
383
+ routes for. */}
384
+ <Route path="*" element={<NoMatch />} />
385
+ </Route>
386
+ </Routes>
387
+ </div>
388
+ );
389
+ }
390
+
391
+ function Layout() {
392
+ return (
393
+ <div>
394
+ {/* A "layout route" is a good place to put markup you want to
395
+ share across all the pages on your site, like navigation. */}
396
+ <nav>
397
+ <ul>
398
+ <li>
399
+ <Link to="/">Home</Link>
400
+ </li>
401
+ <li>
402
+ <Link to="/about">About</Link>
403
+ </li>
404
+ <li>
405
+ <Link to="/dashboard">Dashboard</Link>
406
+ </li>
407
+ <li>
408
+ <Link to="/nothing-here">Nothing Here</Link>
409
+ </li>
410
+ </ul>
411
+ </nav>
412
+
413
+ <hr />
414
+
415
+ {/* An <Outlet> renders whatever child route is currently active,
416
+ so you can think about this <Outlet> as a placeholder for
417
+ the child routes we defined above. */}
418
+ <Outlet />
419
+ </div>
420
+ );
421
+ }
422
+
423
+ function Home() {
424
+ return (
425
+ <div>
426
+ <h2>Home</h2>
427
+ </div>
428
+ );
429
+ }
430
+
431
+ function About() {
432
+ return (
433
+ <div>
434
+ <h2>About</h2>
435
+ </div>
436
+ );
437
+ }
438
+
439
+ function Dashboard() {
440
+ return (
441
+ <div>
442
+ <h2>Dashboard</h2>
443
+ </div>
444
+ );
445
+ }
446
+
447
+ function NoMatch() {
448
+ return (
449
+ <div>
450
+ <h2>Nothing to see here!</h2>
451
+ <p>
452
+ <Link to="/">Go to the home page</Link>
453
+ </p>
454
+ </div>
455
+ );
456
+ }
457
+ "# ,
458
+ )
459
+ . get_module_ast ( )
460
+ . unwrap ( ) ;
461
+ let symbol_dependency = collect_symbol_dependency ( & module_ast, MOCK_MODULE_PATH ) . unwrap ( ) ;
462
+ let mut symbol_to_routes = SymbolToRoutes :: new ( ) ;
463
+ symbol_to_routes
464
+ . collect_route_dependency ( & module_ast, & symbol_dependency)
465
+ . unwrap ( ) ;
466
+
467
+ assert ! ( symbol_to_routes. table. get( MOCK_MODULE_PATH ) . is_none( ) ) ;
468
+ }
319
469
}
0 commit comments