Skip to content

Commit

Permalink
feat: fix use route history test (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fran McDade authored and Fran McDade committed Jan 5, 2025
1 parent f450367 commit 54c41d7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/useRouteHistory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ describe("useRouteHistory", () => {
Router.events.emit("routeChangeComplete", ROUTES[2]);
Router.events.emit("routeChangeComplete", ROUTES[3]);
});
expect(result.current.callbackUrl()).toBe(ROUTES[2]);
// Use `callbackUrl` with a transform function to capture the full history.
let history;
result.current.callbackUrl((routes) => {
history = routes;
return ROOT_PATH;
});
// After emitting the routes, the history stack is [ROUTES[3], ROUTES[2].
expect(history).toHaveLength(2);
expect(history).toEqual([ROUTES[3], ROUTES[2]]);
});

test("uses transform function if provided", () => {
Expand Down

0 comments on commit 54c41d7

Please sign in to comment.