feat: 增加测试覆盖率并优化代码质量
test: 添加单元测试和端到端测试 refactor: 重构登录页面和上传模块 ci: 更新测试覆盖率阈值至42% build: 添加测试相关依赖 docs: 更新测试文档 style: 修复代码格式问题
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
import { GradientFlow } from './gradient-flow';
|
||||
|
||||
jest.mock('framer-motion', () => ({
|
||||
motion: {
|
||||
div: ({ className }: { className?: string }) => <div className={className} data-testid="gradient-flow" />,
|
||||
},
|
||||
}));
|
||||
|
||||
describe('GradientFlow', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('Rendering', () => {
|
||||
it('should render gradient flow component', () => {
|
||||
const { getByTestId } = render(<GradientFlow />);
|
||||
const component = getByTestId('gradient-flow');
|
||||
expect(component).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should apply custom className', () => {
|
||||
const { getByTestId } = render(<GradientFlow className="custom-class" />);
|
||||
const component = getByTestId('gradient-flow');
|
||||
expect(component).toHaveClass('custom-class');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Props', () => {
|
||||
it('should accept custom colors', () => {
|
||||
const { getByTestId } = render(
|
||||
<GradientFlow colors={['#ff0000', '#00ff00', '#0000ff']} />
|
||||
);
|
||||
const component = getByTestId('gradient-flow');
|
||||
expect(component).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should accept custom duration', () => {
|
||||
const { getByTestId } = render(<GradientFlow duration={20} />);
|
||||
const component = getByTestId('gradient-flow');
|
||||
expect(component).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user