File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,20 @@ describe('validateBranchName', () => {
1414 expect ( isBranchNameValid ( 'Test 1' ) ) . toBe ( false ) ;
1515 } ) ;
1616
17+ it ( 'rejects empty or special top-level names' , ( ) => {
18+ expect ( validateBranchName ( '' ) ) . toBe ( 'empty' ) ;
19+ expect ( validateBranchName ( ' ' ) ) . toBe ( 'empty' ) ;
20+ expect ( validateBranchName ( null as unknown as string ) ) . toBe ( 'empty' ) ;
21+ expect ( validateBranchName ( '@' ) ) . toBe ( 'is-at' ) ;
22+ } ) ;
23+
24+ it ( 'rejects slash and trailing-dot edge cases' , ( ) => {
25+ expect ( validateBranchName ( '/feature/test' ) ) . toBe ( 'starts-with-slash' ) ;
26+ expect ( validateBranchName ( 'feature/test/' ) ) . toBe ( 'ends-with-slash' ) ;
27+ expect ( validateBranchName ( 'feature//test' ) ) . toBe ( 'double-slash' ) ;
28+ expect ( validateBranchName ( 'feature/test.' ) ) . toBe ( 'ends-with-dot' ) ;
29+ } ) ;
30+
1731 it ( 'rejects branch names with invalid git ref patterns' , ( ) => {
1832 expect ( validateBranchName ( 'foo..bar' ) ) . toBe ( 'contains-dot-dot' ) ;
1933 expect ( validateBranchName ( 'foo@{bar' ) ) . toBe ( 'contains-at-open-brace' ) ;
You can’t perform that action at this time.
0 commit comments