@@ -27,7 +27,7 @@ describe('Programmatic API Usage', () => {
2727 }
2828 }
2929 serverInstances = [ ] ;
30-
30+
3131 // Restore original process.argv
3232 process . argv = originalArgv ;
3333 } ) ;
@@ -38,17 +38,20 @@ describe('Programmatic API Usage', () => {
3838 const firstOptions : Partial < CliOptions > = { docsHost : true } ;
3939
4040 const server1 = await start ( firstOptions ) ;
41+
4142 serverInstances . push ( server1 ) ;
4243
4344 expect ( OPTIONS . docsHost ) . toBe ( true ) ;
4445 expect ( OPTIONS . sessionId ) . toBeDefined ( ) ;
4546 const firstSessionId = OPTIONS . sessionId ;
47+
4648 expect ( server1 . isRunning ( ) ) . toBe ( true ) ;
4749
4850 // Second start() call with different options
4951 const secondOptions : Partial < CliOptions > = { docsHost : false } ;
5052
5153 const server2 = await start ( secondOptions ) ;
54+
5255 serverInstances . push ( server2 ) ;
5356
5457 expect ( OPTIONS . docsHost ) . toBe ( false ) ;
@@ -58,6 +61,7 @@ describe('Programmatic API Usage', () => {
5861
5962 // Third start() call with no options
6063 const server3 = await start ( { } ) ;
64+
6165 serverInstances . push ( server3 ) ;
6266
6367 expect ( OPTIONS . docsHost ) . toBe ( false ) ;
@@ -71,20 +75,24 @@ describe('Programmatic API Usage', () => {
7175
7276 // Multiple calls with same options
7377 const server1 = await start ( options ) ;
78+
7479 serverInstances . push ( server1 ) ;
7580 expect ( OPTIONS . docsHost ) . toBe ( true ) ;
7681 expect ( OPTIONS . sessionId ) . toBeDefined ( ) ;
7782 const firstSessionId = OPTIONS . sessionId ;
83+
7884 expect ( server1 . isRunning ( ) ) . toBe ( true ) ;
7985
8086 const server2 = await start ( options ) ;
87+
8188 serverInstances . push ( server2 ) ;
8289 expect ( OPTIONS . docsHost ) . toBe ( true ) ;
8390 expect ( OPTIONS . sessionId ) . toBeDefined ( ) ;
8491 expect ( OPTIONS . sessionId ) . not . toBe ( firstSessionId ) ;
8592 expect ( server2 . isRunning ( ) ) . toBe ( true ) ;
8693
8794 const server3 = await start ( options ) ;
95+
8896 serverInstances . push ( server3 ) ;
8997 expect ( OPTIONS . docsHost ) . toBe ( true ) ;
9098 expect ( OPTIONS . sessionId ) . toBeDefined ( ) ;
@@ -97,14 +105,17 @@ describe('Programmatic API Usage', () => {
97105 const initialOptions : Partial < CliOptions > = { docsHost : true } ;
98106
99107 const server1 = await start ( initialOptions ) ;
108+
100109 serverInstances . push ( server1 ) ;
101110 expect ( OPTIONS . docsHost ) . toBe ( true ) ;
102111 expect ( OPTIONS . sessionId ) . toBeDefined ( ) ;
103112 const firstSessionId = OPTIONS . sessionId ;
113+
104114 expect ( server1 . isRunning ( ) ) . toBe ( true ) ;
105115
106116 // Call with empty options - this will reset to default value
107117 const server2 = await start ( { } ) ;
118+
108119 serverInstances . push ( server2 ) ;
109120 expect ( OPTIONS . docsHost ) . toBe ( false ) ; // Will reset to default
110121 expect ( OPTIONS . sessionId ) . toBeDefined ( ) ;
@@ -113,6 +124,7 @@ describe('Programmatic API Usage', () => {
113124
114125 // Call with undefined options - this will also reset to default value
115126 const server3 = await start ( undefined as any ) ;
127+
116128 serverInstances . push ( server3 ) ;
117129 expect ( OPTIONS . docsHost ) . toBe ( false ) ; // Will reset to default
118130 expect ( OPTIONS . sessionId ) . toBeDefined ( ) ;
@@ -125,25 +137,31 @@ describe('Programmatic API Usage', () => {
125137
126138 // First call
127139 const server1 = await start ( options ) ;
140+
128141 serverInstances . push ( server1 ) ;
129142 const firstDocsHost = OPTIONS . docsHost ;
130143 const firstSessionId = OPTIONS . sessionId ;
144+
131145 expect ( server1 . isRunning ( ) ) . toBe ( true ) ;
132146
133147 // Second call with different options
134148 const secondOptions : Partial < CliOptions > = { docsHost : false } ;
135149
136150 const server2 = await start ( secondOptions ) ;
151+
137152 serverInstances . push ( server2 ) ;
138153 const secondDocsHost = OPTIONS . docsHost ;
139154 const secondSessionId = OPTIONS . sessionId ;
155+
140156 expect ( server2 . isRunning ( ) ) . toBe ( true ) ;
141157
142158 // Third call with original options
143159 const server3 = await start ( options ) ;
160+
144161 serverInstances . push ( server3 ) ;
145162 const thirdDocsHost = OPTIONS . docsHost ;
146163 const thirdSessionId = OPTIONS . sessionId ;
164+
147165 expect ( server3 . isRunning ( ) ) . toBe ( true ) ;
148166
149167 // Verify values changed as expected
@@ -163,18 +181,24 @@ describe('Programmatic API Usage', () => {
163181
164182 // Start multiple calls concurrently
165183 const server1 = await start ( options1 ) ;
184+
166185 serverInstances . push ( server1 ) ;
167186 const firstSessionId = OPTIONS . sessionId ;
187+
168188 expect ( server1 . isRunning ( ) ) . toBe ( true ) ;
169189
170190 const server2 = await start ( options2 ) ;
191+
171192 serverInstances . push ( server2 ) ;
172193 const secondSessionId = OPTIONS . sessionId ;
194+
173195 expect ( server2 . isRunning ( ) ) . toBe ( true ) ;
174196
175197 const server3 = await start ( { } ) ;
198+
176199 serverInstances . push ( server3 ) ;
177200 const thirdSessionId = OPTIONS . sessionId ;
201+
178202 expect ( server3 . isRunning ( ) ) . toBe ( true ) ;
179203
180204 // OPTIONS should reflect the last call
@@ -193,6 +217,7 @@ describe('Programmatic API Usage', () => {
193217 const firstOptions : Partial < CliOptions > = { docsHost : true } ;
194218
195219 const server1 = await start ( firstOptions ) ;
220+
196221 serverInstances . push ( server1 ) ;
197222 expect ( OPTIONS . docsHost ) . toBe ( true ) ;
198223 expect ( server1 . isRunning ( ) ) . toBe ( true ) ;
@@ -201,12 +226,14 @@ describe('Programmatic API Usage', () => {
201226 const secondOptions : Partial < CliOptions > = { docsHost : false } ;
202227
203228 const server2 = await start ( secondOptions ) ;
229+
204230 serverInstances . push ( server2 ) ;
205231 expect ( OPTIONS . docsHost ) . toBe ( false ) ;
206232 expect ( server2 . isRunning ( ) ) . toBe ( true ) ;
207233
208234 // Third call with no options
209235 const server3 = await start ( { } ) ;
236+
210237 serverInstances . push ( server3 ) ;
211238 expect ( OPTIONS . docsHost ) . toBe ( false ) ;
212239 expect ( server3 . isRunning ( ) ) . toBe ( true ) ;
@@ -217,6 +244,7 @@ describe('Programmatic API Usage', () => {
217244
218245 // First call
219246 const server1 = await start ( options ) ;
247+
220248 serverInstances . push ( server1 ) ;
221249 expect ( OPTIONS . docsHost ) . toBe ( true ) ;
222250 expect ( server1 . isRunning ( ) ) . toBe ( true ) ;
@@ -226,6 +254,7 @@ describe('Programmatic API Usage', () => {
226254
227255 // Second call with modified options
228256 const server2 = await start ( options ) ;
257+
229258 serverInstances . push ( server2 ) ;
230259 expect ( OPTIONS . docsHost ) . toBe ( false ) ;
231260 expect ( server2 . isRunning ( ) ) . toBe ( true ) ;
@@ -237,14 +266,17 @@ describe('Programmatic API Usage', () => {
237266
238267 // Start multiple calls concurrently
239268 const server1 = await start ( options1 ) ;
269+
240270 serverInstances . push ( server1 ) ;
241271 expect ( server1 . isRunning ( ) ) . toBe ( true ) ;
242272
243273 const server2 = await start ( options2 ) ;
274+
244275 serverInstances . push ( server2 ) ;
245276 expect ( server2 . isRunning ( ) ) . toBe ( true ) ;
246277
247278 const server3 = await start ( { } ) ;
279+
248280 serverInstances . push ( server3 ) ;
249281 expect ( server3 . isRunning ( ) ) . toBe ( true ) ;
250282
@@ -259,6 +291,7 @@ describe('Programmatic API Usage', () => {
259291 const invalidOptions = { invalidProperty : 'value' } as any ;
260292
261293 const server = await start ( invalidOptions ) ;
294+
262295 serverInstances . push ( server ) ;
263296
264297 // Should not throw and server should be running
@@ -268,11 +301,13 @@ describe('Programmatic API Usage', () => {
268301 it ( 'should handle null/undefined options' , async ( ) => {
269302 // Test with null options
270303 const server1 = await start ( null as any ) ;
304+
271305 serverInstances . push ( server1 ) ;
272306 expect ( server1 . isRunning ( ) ) . toBe ( true ) ;
273307
274308 // Test with undefined options
275309 const server2 = await start ( undefined as any ) ;
310+
276311 serverInstances . push ( server2 ) ;
277312 expect ( server2 . isRunning ( ) ) . toBe ( true ) ;
278313 } ) ;
@@ -281,6 +316,7 @@ describe('Programmatic API Usage', () => {
281316 const emptyOptions = { } ;
282317
283318 const server = await start ( emptyOptions ) ;
319+
284320 serverInstances . push ( server ) ;
285321
286322 // Should not throw and server should be running
0 commit comments