@@ -74,6 +74,55 @@ describe("ConfigCommentParser", () => {
7474 b : null ,
7575 } ) ;
7676 } ) ;
77+
78+ it ( "should return an empty object for an empty string" , ( ) => {
79+ const code = "" ;
80+ const result = commentParser . parseStringConfig ( code , comment ) ;
81+
82+ assert . deepStrictEqual ( result , { } ) ;
83+ } ) ;
84+
85+ it ( "should parse string config with one item, no value, and leading whitespace" , ( ) => {
86+ const code = `${ " " . repeat ( 100000 ) } a` ;
87+ const result = commentParser . parseStringConfig ( code , comment ) ;
88+
89+ assert . deepStrictEqual ( result , {
90+ a : null ,
91+ } ) ;
92+ } ) ;
93+
94+ it ( "should parse string config with one item, no value, and trailing whitespace" , ( ) => {
95+ const code = `a${ " " . repeat ( 100000 ) } ` ;
96+ const result = commentParser . parseStringConfig ( code , comment ) ;
97+
98+ assert . deepStrictEqual ( result , {
99+ a : null ,
100+ } ) ;
101+ } ) ;
102+
103+ it ( "should parse string config with two items, no values, and whitespace in the middle" , ( ) => {
104+ const code = `a${ " " . repeat ( 100000 ) } b` ;
105+ const result = commentParser . parseStringConfig ( code , comment ) ;
106+
107+ assert . deepStrictEqual ( result , {
108+ a : null ,
109+ b : null ,
110+ } ) ;
111+ } ) ;
112+
113+ it ( "should parse string config with multiple items with values separated by commas and lots of whitespace" , ( ) => {
114+ const whitespace = " " . repeat ( 100000 ) ;
115+ const code = `a: 1${ whitespace } ,${ whitespace } b: 2${ whitespace } ,${ whitespace } c: 3${ whitespace } ,${ whitespace } d: 4` ;
116+ const result = commentParser . parseStringConfig ( code , comment ) ;
117+
118+ assert . deepStrictEqual ( result , {
119+ a : "1" ,
120+ b : "2" ,
121+ c : "3" ,
122+ d : "4" ,
123+ } ) ;
124+ } ) ;
125+
77126 } ) ;
78127
79128 describe ( "parseListConfig" , ( ) => {
0 commit comments