|
1 | 1 | import * as React from 'react'; |
2 | 2 | import { expect } from 'chai'; |
3 | 3 | import { spy } from 'sinon'; |
4 | | -import { MemoryRouter, Route, Routes, Link, useLocation } from 'react-router'; |
5 | 4 | import { act, fireEvent, screen, waitFor } from '@mui/internal-test-utils'; |
6 | 5 | import { Menu } from '@base-ui/react/menu'; |
7 | 6 | import { describeConformance, createRenderer, isJSDOM } from '#test-utils'; |
@@ -170,75 +169,6 @@ describe('<Menu.Item />', () => { |
170 | 169 | }); |
171 | 170 | }); |
172 | 171 |
|
173 | | - describe('rendering links', () => { |
174 | | - function One() { |
175 | | - return <div>page one</div>; |
176 | | - } |
177 | | - function Two() { |
178 | | - return <div>page two</div>; |
179 | | - } |
180 | | - function LocationDisplay() { |
181 | | - const location = useLocation(); |
182 | | - return <div data-testid="location">{location.pathname}</div>; |
183 | | - } |
184 | | - |
185 | | - it('react-router <Link>', async () => { |
186 | | - const { user } = await render( |
187 | | - <MemoryRouter initialEntries={['/']}> |
188 | | - <Routes> |
189 | | - <Route path="/" element={<One />} /> |
190 | | - <Route path="/two" element={<Two />} /> |
191 | | - </Routes> |
192 | | - |
193 | | - <LocationDisplay /> |
194 | | - |
195 | | - <Menu.Root open> |
196 | | - <Menu.Portal> |
197 | | - <Menu.Positioner> |
198 | | - <Menu.Popup> |
199 | | - <Menu.Item render={<Link to="/" />}>link 1</Menu.Item> |
200 | | - <Menu.Item render={<Link to="/two" />}>link 2</Menu.Item> |
201 | | - </Menu.Popup> |
202 | | - </Menu.Positioner> |
203 | | - </Menu.Portal> |
204 | | - </Menu.Root> |
205 | | - </MemoryRouter>, |
206 | | - ); |
207 | | - |
208 | | - const [link1, link2] = screen.getAllByRole('menuitem'); |
209 | | - |
210 | | - const locationDisplay = screen.getByTestId('location'); |
211 | | - |
212 | | - expect(screen.getByText(/page one/i)).not.to.equal(null); |
213 | | - |
214 | | - expect(locationDisplay).to.have.text('/'); |
215 | | - |
216 | | - await act(async () => { |
217 | | - link2.focus(); |
218 | | - }); |
219 | | - |
220 | | - await waitFor(() => { |
221 | | - expect(link2).toHaveFocus(); |
222 | | - }); |
223 | | - |
224 | | - await user.keyboard('[Enter]'); |
225 | | - |
226 | | - expect(locationDisplay).to.have.text('/two'); |
227 | | - |
228 | | - expect(screen.getByText(/page two/i)).not.to.equal(null); |
229 | | - |
230 | | - await act(async () => { |
231 | | - link1.focus(); |
232 | | - }); |
233 | | - |
234 | | - await user.keyboard('[Enter]'); |
235 | | - |
236 | | - expect(screen.getByText(/page one/i)).not.to.equal(null); |
237 | | - |
238 | | - expect(locationDisplay).to.have.text('/'); |
239 | | - }); |
240 | | - }); |
241 | | - |
242 | 172 | describe('disabled state', () => { |
243 | 173 | it('can be focused but not interacted with when disabled', async () => { |
244 | 174 | const handleClick = spy(); |
|
0 commit comments