diff --git a/crates/dt_route/src/lib.rs b/crates/dt_route/src/lib.rs index 5b0db14..415e105 100644 --- a/crates/dt_route/src/lib.rs +++ b/crates/dt_route/src/lib.rs @@ -316,4 +316,154 @@ mod tests { ], ) } + + #[test] + fn unsupported_template_literal_path() { + let module_ast = Input::Code( + r#" + const A = "A"; + const B = "B"; + const C = "C"; + + export default { + 'foo': { + path: `${prefix}/route/path`, + layouts: [A, B], + page: C + }, + }; + "#, + ) + .get_module_ast() + .unwrap(); + let symbol_dependency = collect_symbol_dependency(&module_ast, MOCK_MODULE_PATH).unwrap(); + let mut symbol_to_routes = SymbolToRoutes::new(); + symbol_to_routes + .collect_route_dependency(&module_ast, &symbol_dependency) + .unwrap(); + + assert!(symbol_to_routes + .table + .get(MOCK_MODULE_PATH) + .unwrap() + .is_empty()); + } + + #[test] + fn unsupported_react_router() { + let module_ast = Input::Code( + // Copied from https://github.com/remix-run/react-router/blob/dev/examples/basic/src/App.tsx + r#" + import { Routes, Route, Outlet, Link } from "react-router-dom"; + + export default function App() { + return ( +
+

Basic Example

+ +

+ This example demonstrates some of the core features of React Router + including nested <Route>s,{" "} + <Outlet>s, <Link>s, and using a + "*" route (aka "splat route") to render a "not found" page when someone + visits an unrecognized URL. +

+ + {/* Routes nest inside one another. Nested route paths build upon + parent route paths, and nested route elements render inside + parent route elements. See the note about below. */} + + }> + } /> + } /> + } /> + + {/* Using path="*"" means "match anything", so this route + acts like a catch-all for URLs that we don't have explicit + routes for. */} + } /> + + +
+ ); + } + + function Layout() { + return ( +
+ {/* A "layout route" is a good place to put markup you want to + share across all the pages on your site, like navigation. */} + + +
+ + {/* An renders whatever child route is currently active, + so you can think about this as a placeholder for + the child routes we defined above. */} + +
+ ); + } + + function Home() { + return ( +
+

Home

+
+ ); + } + + function About() { + return ( +
+

About

+
+ ); + } + + function Dashboard() { + return ( +
+

Dashboard

+
+ ); + } + + function NoMatch() { + return ( +
+

Nothing to see here!

+

+ Go to the home page +

+
+ ); + } + "#, + ) + .get_module_ast() + .unwrap(); + let symbol_dependency = collect_symbol_dependency(&module_ast, MOCK_MODULE_PATH).unwrap(); + let mut symbol_to_routes = SymbolToRoutes::new(); + symbol_to_routes + .collect_route_dependency(&module_ast, &symbol_dependency) + .unwrap(); + + assert!(symbol_to_routes.table.get(MOCK_MODULE_PATH).is_none()); + } }