Skip to content

Commit

Permalink
fix: add unit test for NavLink relative=path
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Oct 12, 2022
1 parent 39390dd commit 10727af
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/react-router-dom/__tests__/nav-link-active-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,33 @@ describe("NavLink", () => {
});
});
});

describe("when it matches with relative=path links", () => {
it("applies the default 'active' className to the underlying <a>", () => {
let renderer: TestRenderer.ReactTestRenderer;
TestRenderer.act(() => {
renderer = TestRenderer.create(
<MemoryRouter initialEntries={["/contacts/1"]}>
<Routes>
<Route
path="contacts/:id"
element={
<NavLink to="../1" relative="path">
Link
</NavLink>
}
/>
</Routes>
</MemoryRouter>
);
});

let anchor = renderer.root.findByType("a");

expect(anchor.props.href).toEqual("/contacts/1");
expect(anchor.props.className).toEqual("active");
});
});
});

describe("NavLink using a data router", () => {
Expand Down

0 comments on commit 10727af

Please sign in to comment.