ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/llms-txt-hub / apps/web/app/api/cli/stats/__tests__/route.test.ts

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/llms-txt-hub / apps/web/app/api/cli/stats/__tests__/route.test.ts
DateNot specified in source
RepositoryJanady13/llms-txt-hub
Revisione0f4bf978d4df168369c7601d9c5f5ea89e84377
Branchmain
Path or archive memberapps/web/app/api/cli/stats/__tests__/route.test.ts
Original SHA-2560895be7ebe270763cd91e8f827409c63b5a34df0dd5cf1352559b9f537f171d0
Git blob SHA65ac419202e3d4f3c35dc37ba5c4a320f3108338
Reading-copy SHA-2560895be7ebe270763cd91e8f827409c63b5a34df0dd5cf1352559b9f537f171d0

Original source ↗

Recovered source transcript

import { createMockRequest } from '@/app/api/__tests__/test-helpers' import { GET } from '@/app/api/cli/stats/[slug]/route' const mockHget = jest.fn() const mockRedisClient = { hget: mockHget } jest.mock('@/lib/redis', () => ({ __esModule: true, getRawClient: jest.fn(() => mockRedisClient) })) function callGET(slug: string) { const request = createMockRequest(`/api/cli/stats/${slug}`) return GET(request, { params: Promise.resolve({ slug }) }) } describe('/api/cli/stats/[slug]', () => { beforeEach(() => { jest.clearAllMocks() }) it('returns the install count for a valid slug', async () => { mockHget.mockResolvedValue(42) const response = await callGET('astro') const data = await response.json() expect(response.status).toBe(200) expect(data.count).toBe(42) expect(mockHget).toHaveBeenCalledWith('telemetry:skills:total', 'astro') }) it('returns 0 for a slug with no installs', async () => { mockHget.mockResolvedValue(null) const response = await callGET('unknown-skill') const data = await response.json() expect(response.status).toBe(200) expect(data.count).toBe(0) }) it('returns 0 when Redis is unavailable', async () => { const { getRawClient } = require('@/lib/redis') ;(getRawClient as jest.Mock).mockReturnValueOnce(null) const response = await callGET('astro') const data = await response.json() expect(response.status).toBe(200) expect(data.count).toBe(0) }) it('returns 0 on Redis errors', async () => { mockHget.mockRejectedValue(new Error('Connection failed')) const response = await callGET('astro') const data = await response.json() expect(response.status).toBe(200) expect(data.count).toBe(0) }) it('sets cache headers for CDN caching', async () => { mockHget.mockResolvedValue(10) const response = await callGET('react') expect(response.headers.get('Cache-Control')).toBe( 'public, s-maxage=300, stale-while-revalidate=600' ) }) })

Search equations, builds, manuscript text, and recovered sources.