-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for matchRoutes returning the same object
- Loading branch information
Showing
4 changed files
with
29 additions
and
20 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
packages/react-router/__tests__/__snapshots__/useOutlet-test.tsx.snap
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
packages/react-router/__tests__/__snapshots__/useRoutes-test.tsx.snap
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as React from "react"; | ||
import { Outlet, matchRoutes } from "react-router"; | ||
|
||
describe("matchRoutes", () => { | ||
it("returns the same route object on match.route as the one that was passed in", () => { | ||
let userProfileRoute = { path: ":id", element: <h1>user profile </h1> }; | ||
let usersRoute = { | ||
path: "/users", | ||
element: ( | ||
<h1> | ||
users <Outlet /> | ||
</h1> | ||
), | ||
children: [userProfileRoute] | ||
}; | ||
|
||
let matches = matchRoutes([usersRoute], "/users/mj")!; | ||
|
||
expect(matches).not.toBeNull(); | ||
expect(matches[0].route).toBe(usersRoute); | ||
expect(matches[1].route).toBe(userProfileRoute); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters