ant-design/components/breadcrumb/__tests__/router.test.tsx
dependabot[bot] 78cf6ac420
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 from 6.28.0 to 7.0.0 in the dev-dependencies group (#51744)
* 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>
2024-11-25 01:17:34 +08:00

116 lines
2.8 KiB
TypeScript

import React from 'react';
import { MemoryRouter, useLocation } from 'react-router-dom';
import type { Location as ReactRouterLocation } from 'react-router-dom';
import { render } from '../../../tests/utils';
import Breadcrumb from '../index';
describe('react router', () => {
beforeAll(() => {
jest.useFakeTimers();
});
afterAll(() => {
jest.useRealTimers();
});
it('memoizes the current location', () => {
let location1: ReactRouterLocation | undefined;
const CaptureLocation1: React.FC = () => {
location1 = useLocation();
return null;
};
const { container: container1 } = render(
<MemoryRouter>
<CaptureLocation1 />
</MemoryRouter>,
);
expect(container1).toBeTruthy();
expect(location1).toBeDefined();
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 legacy', () => {
const routes = [
{
name: 'home',
breadcrumbName: 'Home',
path: '/',
childRoutes: [
{
name: 'apps',
breadcrumbName: 'Application List',
path: 'apps',
childRoutes: [
{
name: 'app',
breadcrumbName: 'Application:id',
path: ':id',
childRoutes: [
{
name: 'detail',
breadcrumbName: 'Detail',
path: 'detail',
},
],
},
],
},
],
},
{
name: 'apps',
breadcrumbName: 'Application List',
path: 'apps',
childRoutes: [
{
name: 'app',
breadcrumbName: 'Application:id',
path: ':id',
childRoutes: [
{
name: 'detail',
breadcrumbName: 'Detail',
path: 'detail',
},
],
},
],
},
{
name: 'app',
breadcrumbName: 'Application:id',
path: ':id',
childRoutes: [
{
name: 'detail',
breadcrumbName: 'Detail',
path: 'detail',
},
],
},
{
name: 'detail',
breadcrumbName: 'Detail',
path: 'detail',
},
];
const { asFragment } = render(<Breadcrumb routes={routes} params={{ id: 1 }} />);
expect(asFragment().firstChild).toMatchSnapshot();
});
});