feat: implement dark mode infrastructure, optimize images, and add SEO structured data
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 10m16s
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 10m16s
This commit is contained in:
71
app/__tests__/api/tech-stack.test.tsx
Normal file
71
app/__tests__/api/tech-stack.test.tsx
Normal file
@@ -0,0 +1,71 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { GET } from '@/app/api/tech-stack/route';
|
||||
import { getTechStack } from '@/lib/directus';
|
||||
|
||||
jest.mock('@/lib/directus', () => ({
|
||||
getTechStack: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('next/server', () => ({
|
||||
NextRequest: jest.fn((url) => ({
|
||||
url,
|
||||
})),
|
||||
NextResponse: {
|
||||
json: jest.fn((data, options) => ({
|
||||
json: async () => data,
|
||||
status: options?.status || 200,
|
||||
})),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('GET /api/tech-stack', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should return tech stack from Directus', async () => {
|
||||
const mockTechStack = [
|
||||
{
|
||||
id: '1',
|
||||
key: 'frontend',
|
||||
icon: 'Globe',
|
||||
name: 'Frontend',
|
||||
items: [
|
||||
{ id: '1-1', name: 'React' }
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
(getTechStack as jest.Mock).mockResolvedValue(mockTechStack);
|
||||
|
||||
const request = {
|
||||
url: 'http://localhost/api/tech-stack?locale=en',
|
||||
} as any;
|
||||
|
||||
await GET(request);
|
||||
|
||||
expect(NextResponse.json).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
techStack: mockTechStack,
|
||||
source: 'directus',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('should return fallback when no tech stack found', async () => {
|
||||
(getTechStack as jest.Mock).mockResolvedValue(null);
|
||||
|
||||
const request = {
|
||||
url: 'http://localhost/api/tech-stack?locale=en',
|
||||
} as any;
|
||||
|
||||
await GET(request);
|
||||
|
||||
expect(NextResponse.json).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
techStack: null,
|
||||
source: 'fallback',
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user