@@ -328,6 +328,61 @@ describe('getFullDashboardData', () => {
328328 expect ( totalClockCommits ) . toBe ( 8 ) ; // 3 + 0 + 5 from mockCalendar
329329 } ) ;
330330
331+ it ( 'maps contribution counts to correct intensity levels' , async ( ) => {
332+ const intensityCalendar : ContributionCalendar = {
333+ totalContributions : 30 ,
334+ weeks : [
335+ {
336+ contributionDays : [
337+ { contributionCount : 0 , date : '2024-06-10' } ,
338+ { contributionCount : 2 , date : '2024-06-11' } ,
339+ { contributionCount : 5 , date : '2024-06-12' } ,
340+ { contributionCount : 8 , date : '2024-06-13' } ,
341+ { contributionCount : 15 , date : '2024-06-14' } ,
342+ ] ,
343+ } ,
344+ ] ,
345+ } ;
346+
347+ vi . mocked ( fetch ) . mockImplementation ( async ( url : any ) => {
348+ if ( typeof url === 'string' && url . includes ( '/users/octocat/repos' ) ) {
349+ return mockResponse ( [ ] ) ;
350+ }
351+
352+ if ( typeof url === 'string' && url . includes ( '/users/octocat' ) ) {
353+ return mockResponse ( {
354+ login : 'octocat' ,
355+ name : 'The Octocat' ,
356+ avatar_url : 'avatar.png' ,
357+ public_repos : 0 ,
358+ followers : 0 ,
359+ following : 0 ,
360+ created_at : '2020-01-01T00:00:00Z' ,
361+ } ) ;
362+ }
363+
364+ return mockResponse ( {
365+ data : {
366+ user : {
367+ contributionsCollection : {
368+ contributionCalendar : intensityCalendar ,
369+ } ,
370+ } ,
371+ } ,
372+ } ) ;
373+ } ) ;
374+
375+ const result = await getFullDashboardData ( 'octocat' ) ;
376+
377+ const activities = result . activity ;
378+
379+ expect ( activities [ 0 ] . intensity ) . toBe ( 0 ) ;
380+ expect ( activities [ 1 ] . intensity ) . toBe ( 1 ) ;
381+ expect ( activities [ 2 ] . intensity ) . toBe ( 2 ) ;
382+ expect ( activities [ 3 ] . intensity ) . toBe ( 3 ) ;
383+ expect ( activities [ 4 ] . intensity ) . toBe ( 4 ) ;
384+ } ) ;
385+
331386 it ( 'throws if profile fetch fails' , async ( ) => {
332387 vi . mocked ( fetch ) . mockImplementation ( async ( url : any ) => {
333388 if ( typeof url === 'string' && url . includes ( '/users/octocat/repos' ) ) {
0 commit comments