refactor: modify layout to use ClientOnly and BackgroundBlobsClient components fix: correct import statement for ActivityFeed in the main page fix: enhance sitemap fetching logic with error handling and mock support refactor: convert BackgroundBlobs to default export for consistency refactor: simplify ErrorBoundary component and improve error handling UI chore: update framer-motion to version 12.24.10 in package.json and package-lock.json test: add minimal Prisma Client mock for testing purposes feat: create BackgroundBlobsClient for dynamic import of BackgroundBlobs feat: implement ClientOnly component to handle client-side rendering feat: add custom error handling components for better user experience
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { GET } from '@/app/api/fetchProject/route';
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
|
|
// Mock node-fetch so the route uses it as a reliable fallback
|
|
jest.mock('node-fetch', () => ({
|
|
__esModule: true,
|
|
default: jest.fn(() =>
|
|
Promise.resolve({
|
|
ok: true,
|
|
json: () =>
|
|
Promise.resolve({
|
|
posts: [
|
|
{
|
|
id: '67aaffc3709c60000117d2d9',
|
|
title: 'Blockchain Based Voting System',
|
|
meta_description: 'This project aims to revolutionize voting systems by leveraging blockchain to ensure security, transparency, and immutability.',
|
|
slug: 'blockchain-based-voting-system',
|
|
updated_at: '2025-02-13T16:54:42.000+00:00',
|
|
},
|
|
],
|
|
}),
|
|
})
|
|
),
|
|
}));
|
|
|
|
jest.mock('next/server', () => ({
|
|
NextResponse: {
|
|
json: jest.fn(),
|
|
},
|
|
}));
|
|
describe('GET /api/fetchProject', () => {
|
|
beforeAll(() => {
|
|
process.env.GHOST_API_URL = 'http://localhost:2368';
|
|
process.env.GHOST_API_KEY = 'some-key';
|
|
});
|
|
|
|
it('should fetch a project by slug', async () => {
|
|
const mockRequest = {
|
|
url: 'http://localhost/api/fetchProject?slug=blockchain-based-voting-system',
|
|
} as unknown as NextRequest;
|
|
|
|
await GET(mockRequest);
|
|
|
|
expect(NextResponse.json).toHaveBeenCalledWith({
|
|
posts: [
|
|
{
|
|
id: '67aaffc3709c60000117d2d9',
|
|
title: 'Blockchain Based Voting System',
|
|
meta_description: 'This project aims to revolutionize voting systems by leveraging blockchain to ensure security, transparency, and immutability.',
|
|
slug: 'blockchain-based-voting-system',
|
|
updated_at: '2025-02-13T16:54:42.000+00:00',
|
|
},
|
|
],
|
|
});
|
|
});
|
|
}); |