Skip to content

Commit 2e7b313

Browse files
committed
test(api): verify stale-while-revalidate=86400 in cache header
1 parent 9918dc2 commit 2e7b313

3 files changed

Lines changed: 8195 additions & 0 deletions

File tree

app/api/streak/route.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,18 @@ describe('GET /api/streak', () => {
430430
expect(body).toContain('CURRENT_STREAK');
431431
});
432432
});
433+
434+
describe('stale-while-revalidate cache header', () => {
435+
it('contains stale-while-revalidate=86400 for normal request', async () => {
436+
const response = await GET(makeRequest({ user: 'octocat' }));
437+
438+
expect(response.headers.get('Cache-Control')).toContain('stale-while-revalidate=86400');
439+
});
440+
441+
it('does NOT contain stale-while-revalidate when ?refresh=true', async () => {
442+
const response = await GET(makeRequest({ user: 'octocat', refresh: 'true' }));
443+
444+
expect(response.headers.get('Cache-Control')).not.toContain('stale-while-revalidate=86400');
445+
});
446+
});
433447
});

0 commit comments

Comments
 (0)