b207bfa7af
test: 添加单元测试和端到端测试 refactor: 重构登录页面和上传模块 ci: 更新测试覆盖率阈值至42% build: 添加测试相关依赖 docs: 更新测试文档 style: 修复代码格式问题
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
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();
|
|
});
|
|
});
|
|
});
|