Skip to content

Commit d688f11

Browse files
committed
test(api): strengthen validation tests for speed and scale query params
1 parent 8cba703 commit d688f11

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

app/api/streak/route.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ describe('GET /api/streak', () => {
195195
// "5" doesn't match /^\d+(\.\d+)?s$/, so the default kicks in.
196196
expect(body).toContain('8s');
197197
});
198+
199+
it('falls back to 8s when speed=10 is provided', async () => {
200+
const response = await GET(makeRequest({ user: 'octocat', speed: '10' }));
201+
const body = await response.text();
202+
203+
expect(body).toContain('8s');
204+
});
198205
});
199206

200207
describe('scale parameter', () => {
@@ -211,6 +218,12 @@ describe('GET /api/streak', () => {
211218

212219
expect(response.status).toBe(200);
213220
});
221+
222+
it('defaults to linear scale when scale=foo is given', async () => {
223+
const response = await GET(makeRequest({ user: 'octocat', scale: 'foo' }));
224+
225+
expect(response.status).toBe(200);
226+
});
214227
});
215228

216229
describe('theme parameter', () => {

0 commit comments

Comments
 (0)