- Fix fill and priority boolean attributes in Hero component - Improve next/image mock in Jest setup to handle boolean props correctly - Enhance pre-push hook with better Docker detection and error handling - Make Docker build test non-blocking (warnings instead of errors) - Add executable permissions for secret check script - Prevent React DOM warnings in tests
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import 'whatwg-fetch';
|
|
import React from "react";
|
|
import { render } from '@testing-library/react';
|
|
import { ToastProvider } from '@/components/Toast';
|
|
|
|
// Mock react-responsive-masonry
|
|
jest.mock("react-responsive-masonry", () => ({
|
|
__esModule: true,
|
|
default: ({ children }: { children: React.ReactNode }) =>
|
|
React.createElement("div", null, children),
|
|
get ResponsiveMasonry() {
|
|
const ResponsiveMasonryComponent = ({ children }: { children: React.ReactNode }) =>
|
|
React.createElement("div", null, children);
|
|
ResponsiveMasonryComponent.displayName = 'ResponsiveMasonry';
|
|
return ResponsiveMasonryComponent;
|
|
},
|
|
}));
|
|
|
|
// Mock next/link
|
|
jest.mock('next/link', () => {
|
|
const LinkComponent = ({ children }: { children: React.ReactNode }) => children;
|
|
LinkComponent.displayName = 'Link';
|
|
return LinkComponent;
|
|
});
|
|
|
|
// Mock next/image
|
|
jest.mock('next/image', () => {
|
|
const ImageComponent = ({ src, alt, fill, priority, ...props }: Record<string, unknown>) => {
|
|
// Convert boolean props to strings for DOM compatibility
|
|
const domProps: Record<string, unknown> = { src, alt };
|
|
if (fill) domProps.style = { width: '100%', height: '100%', objectFit: 'cover' };
|
|
if (priority) domProps.loading = 'eager';
|
|
|
|
return React.createElement('img', { ...domProps, ...props });
|
|
};
|
|
ImageComponent.displayName = 'Image';
|
|
return ImageComponent;
|
|
});
|
|
|
|
// Custom render function with ToastProvider
|
|
const customRender = (ui: React.ReactElement, options = {}) =>
|
|
render(ui, {
|
|
wrapper: ({ children }) => React.createElement(ToastProvider, null, children),
|
|
...options,
|
|
});
|
|
|
|
// Re-export everything
|
|
export * from '@testing-library/react';
|
|
export { customRender as render }; |