Skip to content

Commit 6c6aa97

Browse files
authored
test(api): add hide params route tests (JhaSourav07#748)
2 parents a2a0106 + fc66a32 commit 6c6aa97

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

app/api/streak/route.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,36 @@ describe('GET /api/streak', () => {
389389
});
390390
});
391391

392+
describe('hide parameters', () => {
393+
it('removes the username title when hide_title=true', async () => {
394+
const response = await GET(makeRequest({ user: 'octocat', hide_title: 'true' }));
395+
const body = await response.text();
396+
397+
expect(body).not.toContain('OCTOCAT');
398+
});
399+
400+
it('keeps the username title when hide_title=false', async () => {
401+
const response = await GET(makeRequest({ user: 'octocat', hide_title: 'false' }));
402+
const body = await response.text();
403+
404+
expect(body).toContain('OCTOCAT');
405+
});
406+
407+
it('removes the stats section when hide_stats=true', async () => {
408+
const response = await GET(makeRequest({ user: 'octocat', hide_stats: 'true' }));
409+
const body = await response.text();
410+
411+
expect(body).not.toContain('CURRENT_STREAK');
412+
});
413+
414+
it('keeps the stats section when hide_stats=false', async () => {
415+
const response = await GET(makeRequest({ user: 'octocat', hide_stats: 'false' }));
416+
const body = await response.text();
417+
418+
expect(body).toContain('CURRENT_STREAK');
419+
});
420+
});
421+
392422
describe('error handling', () => {
393423
it('returns 500 with SVG content type when fetchGitHubContributions throws', async () => {
394424
vi.mocked(fetchGitHubContributions).mockRejectedValue(new Error('API is down'));

0 commit comments

Comments
 (0)