@@ -15,13 +15,13 @@ describe('base utils', () => {
1515 SC_OVERRIDE_BRANCH_NAME : undefined ,
1616 SC_OVERRIDE_IS_PR : undefined ,
1717 }
18- expect ( getBranchInfo ( env , 'master' ) ) . toEqual ( < BranchInfo > {
18+ expect ( getBranchInfo ( env , 'master' ) ) . toEqual ( {
1919 stage : 'master' ,
2020 isPr : false ,
2121 isProd : true ,
2222 name : 'master' ,
2323 branchName : 'master' ,
24- } )
24+ } satisfies BranchInfo )
2525 } )
2626
2727 test ( 'works locally when not master' , ( ) => {
@@ -53,9 +53,9 @@ describe('base utils', () => {
5353 const env : Partial < GithubActionEnv & CustomGitHubContext > = {
5454 GITHUB_ACTIONS : 'true' ,
5555 GITHUB_EVENT_NAME : 'push' ,
56- GITHUB_CONTEXT : JSON . stringify ( < Partial < GitHubContext > > {
56+ GITHUB_CONTEXT : JSON . stringify ( {
5757 ref : 'refs/heads/master' ,
58- } ) ,
58+ } satisfies Partial < GitHubContext > ) ,
5959 }
6060 expect ( getBranchInfo ( env ) ) . toEqual ( {
6161 branchName : 'master' ,
@@ -72,13 +72,13 @@ describe('base utils', () => {
7272 SC_OVERRIDE_BRANCH_NAME : '#1313-on-branch-to-override-them-all' ,
7373 SC_OVERRIDE_IS_PR : 'true' ,
7474 }
75- expect ( getBranchInfo ( env , 'master' ) ) . toEqual ( < BranchInfo > {
75+ expect ( getBranchInfo ( env , 'master' ) ) . toEqual ( {
7676 stage : 'pr1313' ,
7777 isPr : true ,
7878 isProd : false ,
7979 name : 'on-branch-to-override-them-all' ,
8080 branchName : '#1313-on-branch-to-override-them-all' ,
81- } )
81+ } satisfies BranchInfo )
8282 } )
8383 } )
8484
@@ -94,6 +94,16 @@ describe('base utils', () => {
9494
9595 expect ( parseBranchName ( '#72- whatever' ) . branchId ) . toBe ( 72 )
9696 expect ( parseBranchName ( 'feature/#72-ok' ) . branchId ) . toBe ( 72 )
97+ expect ( parseBranchName ( '1-foobar' ) ) . toEqual ( { branchId : 1 , branchName : 'foobar' } satisfies ReturnType <
98+ typeof parseBranchName
99+ > )
100+ expect ( parseBranchName ( 'feat/42-foo-bar-baz' ) ) . toEqual ( {
101+ branchId : 42 ,
102+ branchName : 'foo-bar-baz' ,
103+ } satisfies ReturnType < typeof parseBranchName > )
104+ expect ( parseBranchName ( '007-oh-james' ) ) . toEqual ( { branchId : 7 , branchName : 'oh-james' } satisfies ReturnType <
105+ typeof parseBranchName
106+ > )
97107 } )
98108
99109 test ( 'works for github copilot created branches' , ( ) => {
@@ -107,8 +117,10 @@ describe('base utils', () => {
107117
108118 test ( 'throws when invalid pattern' , ( ) => {
109119 expect ( ( ) => parseBranchName ( 'whrjwe' ) ) . toThrow ( )
110- expect ( ( ) => parseBranchName ( 'copilot/123-fix' ) ) . toThrow ( )
111120 expect ( ( ) => parseBranchName ( 'feat/copilot/fix-123' ) ) . toThrow ( )
121+ expect ( ( ) => parseBranchName ( '/42-foo' ) ) . toThrow ( )
122+ expect ( ( ) => parseBranchName ( 'fix-7-issues' ) ) . toThrow ( )
123+ expect ( ( ) => parseBranchName ( 'fix7-issues' ) ) . toThrow ( )
112124 } )
113125 } )
114126
0 commit comments