chore(deps-dev): bump react-router-dom from 6.28.0 to 7.0.0 in the dev-dependencies group (#51744)
Some checks are pending
Publish Any Commit / build (push) Waiting to run
🔀 Sync mirror to Gitee / mirror (push) Waiting to run
✅ test / lint (push) Waiting to run
✅ test / test-react-legacy (16, 1/2) (push) Waiting to run
✅ test / test-react-legacy (16, 2/2) (push) Waiting to run
✅ test / test-react-legacy (17, 1/2) (push) Waiting to run
✅ test / test-react-legacy (17, 2/2) (push) Waiting to run
✅ test / test-node (push) Waiting to run
✅ test / test-react-latest (dom, 1/2) (push) Waiting to run
✅ test / test-react-latest (dom, 2/2) (push) Waiting to run
✅ test / test-react-latest-dist (dist, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist, 2/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 1/2) (push) Blocked by required conditions
✅ test / test-react-latest-dist (dist-min, 2/2) (push) Blocked by required conditions
✅ test / test-coverage (push) Blocked by required conditions
✅ test / build (push) Waiting to run
✅ test / test lib/es module (es, 1/2) (push) Waiting to run
✅ test / test lib/es module (es, 2/2) (push) Waiting to run
✅ test / test lib/es module (lib, 1/2) (push) Waiting to run
✅ test / test lib/es module (lib, 2/2) (push) Waiting to run
👁️ Visual Regression Persist Start / test image (push) Waiting to run

* chore(deps-dev): bump react-router-dom in the dev-dependencies group

Bumps the dev-dependencies group with 1 update: [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom).


Updates `react-router-dom` from 6.28.0 to 7.0.0
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@7.0.0/packages/react-router-dom)

---
updated-dependencies:
- dependency-name: react-router-dom
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: dev-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>

* test: fix test case

* fix: fix

* fix: fix rename

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: lijianan <574980606@qq.com>
This commit is contained in:
dependabot[bot] 2024-11-25 01:17:34 +08:00 committed by GitHub
parent f669940eeb
commit 78cf6ac420
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 75 deletions

View File

@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`react router react router 3 1`] = `
exports[`react router react router legacy 1`] = `
<nav
class="ant-breadcrumb"
>

View File

@ -1,29 +1,10 @@
import React, { useMemo } from 'react';
import type { RouterProps } from 'react-router-dom';
import { Link, MemoryRouter, Route, Routes, useLocation, useNavigate } from 'react-router-dom';
import React from 'react';
import { MemoryRouter, useLocation } from 'react-router-dom';
import type { Location as ReactRouterLocation } from 'react-router-dom';
import { fireEvent, render } from '../../../tests/utils';
import { render } from '../../../tests/utils';
import Breadcrumb from '../index';
const Apps: React.FC = () => (
<ul className="app-list">
<li>
<Link to="/apps/1">Application1</Link><Link to="/apps/1/detail">Detail</Link>
</li>
<li>
<Link to="/apps/2">Application2</Link><Link to="/apps/2/detail">Detail</Link>
</li>
</ul>
);
const breadcrumbNameMap = {
'/apps': 'Application List',
'/apps/1': 'Application1',
'/apps/2': 'Application2',
'/apps/1/detail': 'Detail',
'/apps/2/detail': 'Detail',
};
describe('react router', () => {
beforeAll(() => {
jest.useFakeTimers();
@ -33,63 +14,37 @@ describe('react router', () => {
jest.useRealTimers();
});
it('react router 6', () => {
const Home: React.FC = () => {
const location = useLocation();
const navigate = useNavigate();
const pathSnippets = location.pathname.split('/').filter((i) => i);
const extraBreadcrumbItems = pathSnippets.map((_, index) => {
const url = `/${pathSnippets.slice(0, index + 1).join('/')}`;
return (
<Breadcrumb.Item key={url}>
<Link to={url}>{breadcrumbNameMap[url as keyof typeof breadcrumbNameMap]}</Link>
</Breadcrumb.Item>
);
});
const breadcrumbItems = [
<Breadcrumb.Item key="home">
<Link to="/">Home</Link>
</Breadcrumb.Item>,
].concat(extraBreadcrumbItems);
const componentProps = useMemo<RouterProps>(
() => ({ component: Apps }) as unknown as RouterProps,
[],
);
const renderProps = useMemo<RouterProps>(
() => ({ render: () => <span>Home Page</span> }) as unknown as RouterProps,
[],
);
return (
<div className="demo">
<div className="demo-nav">
<a onClick={() => navigate('/')}>Home</a>
<a onClick={() => navigate('/apps')}>Application List</a>
</div>
<Routes>
<Route path="/apps" {...componentProps} />
<Route {...renderProps} />
</Routes>
<Breadcrumb>{breadcrumbItems}</Breadcrumb>
</div>
);
it('memoizes the current location', () => {
let location1: ReactRouterLocation | undefined;
const CaptureLocation1: React.FC = () => {
location1 = useLocation();
return null;
};
const { container } = render(
<MemoryRouter initialEntries={['/']} initialIndex={0}>
<Home />
const { container: container1 } = render(
<MemoryRouter>
<CaptureLocation1 />
</MemoryRouter>,
);
expect(container.querySelectorAll('.ant-breadcrumb-link').length).toBe(1);
expect(container.querySelectorAll('.ant-breadcrumb-link')[0].textContent).toBe('Home');
expect(container1).toBeTruthy();
expect(location1).toBeDefined();
fireEvent.click(container.querySelectorAll('.demo-nav a')[1]);
expect(container.querySelectorAll('.ant-breadcrumb-link').length).toBe(2);
expect(container.querySelectorAll('.ant-breadcrumb-link')[1].textContent).toBe(
'Application List',
let location2: ReactRouterLocation | undefined;
const CaptureLocation2: React.FC = () => {
location2 = useLocation();
return null;
};
const { container: container2 } = render(
<MemoryRouter>
<CaptureLocation2 />
</MemoryRouter>,
);
expect(container2).toBeTruthy();
expect(location2).toBeDefined();
expect(location1).toEqual(location2);
});
it('react router 3', () => {
it('react router legacy', () => {
const routes = [
{
name: 'home',

View File

@ -294,7 +294,7 @@
"react-infinite-scroll-component": "^6.1.0",
"react-intersection-observer": "^9.13.1",
"react-resizable": "^3.0.5",
"react-router-dom": "^6.27.0",
"react-router-dom": "^7.0.1",
"react-sticky-box": "^2.0.5",
"regenerator-runtime": "^0.14.1",
"rehype-stringify": "^10.0.1",