@@ -30,8 +30,37 @@ describe('GET /api/github', () => {
3030
3131 it ( 'calls getFullDashboardData with { bypassCache: false } when refresh is omitted' , async ( ) => {
3232 await GET ( makeRequest ( { username : 'octocat' } ) ) ;
33+ expect ( getFullDashboardData ) . toHaveBeenCalledWith ( 'octocat' , {
34+ bypassCache : false ,
35+ } ) ;
36+ } ) ;
37+ it ( 'returns 400 when username contains invalid characters' , async ( ) => {
38+ const response = await GET ( makeRequest ( { username : '@@@@@' } ) ) ;
39+ const body = await response . json ( ) ;
3340
34- expect ( getFullDashboardData ) . toHaveBeenCalledWith ( 'octocat' , { bypassCache : false } ) ;
41+ expect ( response . status ) . toBe ( 400 ) ;
42+ expect ( body . error ) . toContain ( 'Invalid parameters' ) ;
43+ } ) ;
44+
45+ it ( 'returns 400 when username contains only whitespace' , async ( ) => {
46+ const response = await GET ( makeRequest ( { username : ' ' } ) ) ;
47+ const body = await response . json ( ) ;
48+
49+ expect ( response . status ) . toBe ( 400 ) ;
50+ expect ( body . error ) . toContain ( 'Invalid parameters' ) ;
51+ } ) ;
52+
53+ it ( 'returns 400 when username exceeds GitHub maximum length' , async ( ) => {
54+ const response = await GET (
55+ makeRequest ( {
56+ username : 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' ,
57+ } )
58+ ) ;
59+
60+ const body = await response . json ( ) ;
61+
62+ expect ( response . status ) . toBe ( 400 ) ;
63+ expect ( body . error ) . toContain ( 'Invalid parameters' ) ;
3564 } ) ;
3665
3766 // Test 1 — missing username → 400
0 commit comments