1+ import "dotenv/config" ;
2+
13import { afterEach , describe , expect , test , vi } from "vitest" ;
24import {
35 createGitHubUserDataFetcher ,
@@ -19,10 +21,7 @@ function makeExecutor(
1921 delayMs = 0 ,
2022) : GitHubFetcherDependencies [ "executor" ] {
2123 return {
22- async execute <
23- TData ,
24- TVariables extends Record < string , unknown > ,
25- > ( params : {
24+ async execute < TData , TVariables extends Record < string , unknown > > ( params : {
2625 operationName : string ;
2726 query : string ;
2827 variables : TVariables ;
@@ -174,8 +173,7 @@ function isGitHubUserData(value: unknown): value is GitHubUserData {
174173 value !== null &&
175174 "avatarUrl" in value &&
176175 "repos" in value &&
177- "pullRequests" in value &&
178- "contributions" in value
176+ "pullRequests" in value
179177 ) ;
180178}
181179
@@ -186,14 +184,11 @@ describe("GitHub user data caching", () => {
186184 test ( "cache hit skips GitHub calls" , async ( ) => {
187185 const cachedPayload : GitHubUserData = {
188186 name : "Cached" ,
187+ location : "any" ,
188+ login : "Cached" ,
189189 avatarUrl : "https://example.com/cached.png" ,
190190 repos : [ ] ,
191191 pullRequests : [ ] ,
192- contributions : {
193- totalCommitContributions : 0 ,
194- totalPullRequestContributions : 0 ,
195- totalIssueContributions : 0 ,
196- } ,
197192 issues : [ ] ,
198193 discussions : [ ] ,
199194 } ;
@@ -266,10 +261,16 @@ describe("GitHub user data caching", () => {
266261 vi . stubEnv ( "GITHUB_ISSUE_COUNT" , "2" ) ;
267262 vi . stubEnv ( "GITHUB_DISCUSSION_COUNT" , "2" ) ;
268263
269- const calls : Array < { operationName : string ; variables : Record < string , unknown > } > = [ ] ;
264+ const calls : Array < {
265+ operationName : string ;
266+ variables : Record < string , unknown > ;
267+ } > = [ ] ;
270268 const fetcher = createGitHubUserDataFetcher ( {
271269 executor : {
272- async execute < TData , TVariables extends Record < string , unknown > > ( params : {
270+ async execute <
271+ TData ,
272+ TVariables extends Record < string , unknown > ,
273+ > ( params : {
273274 operationName : string ;
274275 query : string ;
275276 variables : TVariables ;
@@ -416,8 +417,13 @@ describe("GitHub user data caching", () => {
416417 const result = await fetcher ( "testuser" ) ;
417418
418419 expect ( result . pullRequests ) . toHaveLength ( 2 ) ;
419- expect ( calls . filter ( ( call ) => call . operationName === "FetchUserPullRequests" ) ) . toHaveLength ( 1 ) ;
420- expect ( calls . find ( ( call ) => call . operationName === "FetchUserPullRequests" ) ?. variables . prCount ) . toBe ( 2 ) ;
420+ expect (
421+ calls . filter ( ( call ) => call . operationName === "FetchUserPullRequests" ) ,
422+ ) . toHaveLength ( 1 ) ;
423+ expect (
424+ calls . find ( ( call ) => call . operationName === "FetchUserPullRequests" )
425+ ?. variables . prCount ,
426+ ) . toBe ( 2 ) ;
421427 } ) ;
422428
423429 test ( "cache write failure does not fail request" , async ( ) => {
0 commit comments