* ✨ chore: update CI workflow to include testing and multi-arch build (#29) * ✨ chore: remove unused dependencies from package-lock.json and updated to a better local dev environment (#30) * ✨ test: add unit tests * ✨ test: add unit tests for whole project * ✨ feat: add whatwg-fetch for improved fetch support * ✨ chore: update Node.js version to 22 in workflow * ✨ refactor: update types and improve email handling tests * ✨ refactor: remove unused imports * ✨ fix: normalize image name to lowercase in workflows * ✨ fix: ensure Docker image names are consistently lowercase * ✨ chore: update * ✨ chore: update base URL to use secret variable * ✨ chore: update to login to ghcr * ✨ fix: add missing 'fi' to close if statement in workflow
57 lines
1.9 KiB
TypeScript
57 lines
1.9 KiB
TypeScript
import { GET } from '@/app/api/fetchAllProjects/route';
|
|
import { NextResponse } from 'next/server';
|
|
import { mockFetch } from '@/app/__tests__/__mocks__/mock-fetch';
|
|
|
|
jest.mock('next/server', () => ({
|
|
NextResponse: {
|
|
json: jest.fn(),
|
|
},
|
|
}));
|
|
|
|
describe('GET /api/fetchAllProjects', () => {
|
|
beforeAll(() => {
|
|
process.env.GHOST_API_URL = 'http://localhost:2368';
|
|
process.env.GHOST_API_KEY = 'some-key';
|
|
global.fetch = mockFetch({
|
|
posts: [
|
|
{
|
|
id: '67ac8dfa709c60000117d312',
|
|
title: 'Just Doing Some Testing',
|
|
meta_description: 'Hello bla bla bla bla',
|
|
slug: 'just-doing-some-testing',
|
|
updated_at: '2025-02-13T14:25:38.000+00:00',
|
|
},
|
|
{
|
|
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',
|
|
},
|
|
],
|
|
});
|
|
});
|
|
|
|
it('should return a list of projects', async () => {
|
|
await GET();
|
|
|
|
expect(NextResponse.json).toHaveBeenCalledWith({
|
|
posts: [
|
|
{
|
|
id: '67ac8dfa709c60000117d312',
|
|
title: 'Just Doing Some Testing',
|
|
meta_description: 'Hello bla bla bla bla',
|
|
slug: 'just-doing-some-testing',
|
|
updated_at: '2025-02-13T14:25:38.000+00:00',
|
|
},
|
|
{
|
|
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',
|
|
},
|
|
],
|
|
});
|
|
});
|
|
}); |