mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-31 06:23:47 +00:00
fix: npm install fail need --legacy-peer-deps
This commit is contained in:
+5
-5
@@ -26,12 +26,12 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^6.1.1",
|
||||
"@testing-library/react": "^14.0.0",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@types/jest": "^29.5.3",
|
||||
"@types/react": "19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
||||
"@typescript-eslint/parser": "^6.9.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||
"@typescript-eslint/parser": "^8.0.0",
|
||||
"@umijs/test": "^4.6.32",
|
||||
"eslint": "^8.47.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
@@ -41,10 +41,10 @@
|
||||
"eslint-plugin-prettier": "^5.1.0",
|
||||
"eslint-plugin-react": "^7.33.2",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-unused-imports": "^2.0.0",
|
||||
"eslint-plugin-unused-imports": "^4.4.1",
|
||||
"jest": "^29.6.1",
|
||||
"mockjs": "^1.1.0",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier": "^3.0.0",
|
||||
"prettier-plugin-organize-imports": "^3.2.2",
|
||||
"prettier-plugin-packagejson": "^2.4.3",
|
||||
"ts-jest": "^29.1.0",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import DropOption from './DropOption';
|
||||
|
||||
// Mock antd Dropdown to expose menu items for testing
|
||||
jest.mock('antd', () => {
|
||||
const React = require('react');
|
||||
return {
|
||||
Dropdown: ({ menu, children }: any) =>
|
||||
React.createElement(
|
||||
@@ -31,10 +31,13 @@ jest.mock('antd', () => {
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('@ant-design/icons', () => ({
|
||||
BarsOutlined: () => React.createElement('span', null, 'Bars'),
|
||||
DownOutlined: () => React.createElement('span', null, 'Down'),
|
||||
}));
|
||||
jest.mock('@ant-design/icons', () => {
|
||||
const React = require('react');
|
||||
return {
|
||||
BarsOutlined: () => React.createElement('span', null, 'Bars'),
|
||||
DownOutlined: () => React.createElement('span', null, 'Down'),
|
||||
};
|
||||
});
|
||||
|
||||
test('renders default trigger when no children provided', () => {
|
||||
render(<DropOption menuOptions={[]} />);
|
||||
|
||||
@@ -74,9 +74,9 @@ export default function TopbarControls({ goProfile, onLogout }: Props) {
|
||||
|
||||
const handleProfileClick = (key: string) => {
|
||||
if (key === 'profile') {
|
||||
goProfile && goProfile();
|
||||
goProfile?.();
|
||||
} else if (key === 'logout') {
|
||||
onLogout && onLogout();
|
||||
onLogout?.();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ export default function SortModal({ open, menus, onCancel, onConfirm }: Props) {
|
||||
route: r.route || '/',
|
||||
sort: r.sort,
|
||||
children: r.children ? buildMenuTree(r.children) : undefined,
|
||||
} as MenuItem),
|
||||
}) as MenuItem,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('api', () => {
|
||||
const err = new Error('net fail');
|
||||
(global.fetch as jest.Mock).mockRejectedValue(err);
|
||||
const spy = jest.spyOn(message, 'error') as jest.SpyInstance<any, any>;
|
||||
spy.mockImplementation(() => ({} as any));
|
||||
spy.mockImplementation(() => ({}) as any);
|
||||
await expect(api('/x')).rejects.toThrow('net fail');
|
||||
expect(spy).toBeCalledWith('net fail');
|
||||
spy.mockRestore();
|
||||
@@ -54,7 +54,7 @@ describe('api', () => {
|
||||
json: async () => ({}),
|
||||
});
|
||||
const spy = jest.spyOn(message, 'error') as jest.SpyInstance<any, any>;
|
||||
spy.mockImplementation(() => ({} as any));
|
||||
spy.mockImplementation(() => ({}) as any);
|
||||
await expect(api('/x')).rejects.toThrow('Invalid API response format');
|
||||
expect(spy).toBeCalledWith('Invalid API response format');
|
||||
spy.mockRestore();
|
||||
|
||||
Reference in New Issue
Block a user