Integrate Prisma for content; enhance SEO, i18n, and deployment workflows
Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
@@ -1,26 +1,23 @@
|
||||
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('@/lib/prisma', () => ({
|
||||
prisma: {
|
||||
project: {
|
||||
findUnique: jest.fn(async ({ where }: { where: { slug: string } }) => {
|
||||
if (where.slug !== 'blockchain-based-voting-system') return null;
|
||||
return {
|
||||
id: 2,
|
||||
title: 'Blockchain Based Voting System',
|
||||
metaDescription:
|
||||
'This project aims to revolutionize voting systems by leveraging blockchain to ensure security, transparency, and immutability.',
|
||||
slug: 'blockchain-based-voting-system',
|
||||
updatedAt: new Date('2025-02-13T16:54:42.000Z'),
|
||||
description: null,
|
||||
content: null,
|
||||
};
|
||||
}),
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('next/server', () => ({
|
||||
@@ -29,12 +26,8 @@ jest.mock('next/server', () => ({
|
||||
},
|
||||
}));
|
||||
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 { GET } = await import('@/app/api/fetchProject/route');
|
||||
const mockRequest = {
|
||||
url: 'http://localhost/api/fetchProject?slug=blockchain-based-voting-system',
|
||||
} as unknown as NextRequest;
|
||||
@@ -44,11 +37,11 @@ describe('GET /api/fetchProject', () => {
|
||||
expect(NextResponse.json).toHaveBeenCalledWith({
|
||||
posts: [
|
||||
{
|
||||
id: '67aaffc3709c60000117d2d9',
|
||||
id: '2',
|
||||
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',
|
||||
updated_at: '2025-02-13T16:54:42.000Z',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user