@@ -321,7 +321,7 @@ describe("detectDefaultBranch", () => {
321321 test ( "detects default branch via GitHub API" , async ( ) => {
322322 global . fetch = jest . fn ( ) . mockResolvedValue ( {
323323 ok : true ,
324- json : ( ) => Promise . resolve ( { default_branch : "main " } ) ,
324+ json : ( ) => Promise . resolve ( { default_branch : "dev " } ) ,
325325 } ) ;
326326 const { detectDefaultBranch } = await import (
327327 "../public/scripts/workflow.js"
@@ -333,13 +333,35 @@ describe("detectDefaultBranch", () => {
333333 repo : "r" ,
334334 } ;
335335 const branch = await detectDefaultBranch ( repoInfo ) ;
336- expect ( branch ) . toBe ( "main " ) ;
336+ expect ( branch ) . toBe ( "dev " ) ;
337337 expect ( global . fetch ) . toHaveBeenCalledWith (
338338 "https://api.github.com/repos/o/r" ,
339339 expect . any ( Object ) ,
340340 ) ;
341341 } ) ;
342342
343+ test ( "detects default branch via GitHub Enterprise API" , async ( ) => {
344+ global . fetch = jest . fn ( ) . mockResolvedValue ( {
345+ ok : true ,
346+ json : ( ) => Promise . resolve ( { default_branch : "dev" } ) ,
347+ } ) ;
348+ const { detectDefaultBranch } = await import (
349+ "../public/scripts/workflow.js"
350+ ) ;
351+ const repoInfo = {
352+ origin : "https://mycompany.github.com" ,
353+ hostname : "mycompany.github.com" ,
354+ owner : "o" ,
355+ repo : "r" ,
356+ } ;
357+ const branch = await detectDefaultBranch ( repoInfo ) ;
358+ expect ( branch ) . toBe ( "dev" ) ;
359+ expect ( global . fetch ) . toHaveBeenCalledWith (
360+ "https://mycompany.github.com/api/v3/repos/o/r" ,
361+ expect . any ( Object ) ,
362+ ) ;
363+ } ) ;
364+
343365 test ( "returns null if GitHub API response is not ok" , async ( ) => {
344366 global . fetch = jest . fn ( ) . mockResolvedValue ( { ok : false } ) ;
345367 const { detectDefaultBranch } = await import (
0 commit comments