|
8 | 8 | import { start, type CliOptions, type ServerInstance } from '../src/index'; |
9 | 9 | import { OPTIONS } from '../src/options'; |
10 | 10 |
|
| 11 | +describe('Programmatic API Usage', () => { |
| 12 | + it('should handle multiple start() calls with different options and unique sessionIds', async () => { |
| 13 | + // First start() call |
| 14 | + const firstOptions: Partial<CliOptions> = { docsHost: true }; |
| 15 | + const server1 = await start(firstOptions); |
| 16 | + |
| 17 | + expect(OPTIONS.docsHost).toBe(true); |
| 18 | + expect(OPTIONS.sessionId).toBeDefined(); |
| 19 | + const firstSessionId = OPTIONS.sessionId; |
| 20 | + |
| 21 | + expect(server1.isRunning()).toBe(true); |
| 22 | + |
| 23 | + // Second start() call with different options |
| 24 | + const secondOptions: Partial<CliOptions> = { docsHost: false }; |
| 25 | + const server2 = await start(secondOptions); |
| 26 | + |
| 27 | + expect(OPTIONS.docsHost).toBe(false); |
| 28 | + expect(OPTIONS.sessionId).toBeDefined(); |
| 29 | + expect(OPTIONS.sessionId).not.toBe(firstSessionId); |
| 30 | + expect(server2.isRunning()).toBe(true); |
| 31 | + |
| 32 | + // Third start() call with no options |
| 33 | + const thirdOptions: Partial<CliOptions> = {}; |
| 34 | + const server3 = await start(thirdOptions); |
| 35 | + |
| 36 | + expect(OPTIONS.docsHost).toBe(false); |
| 37 | + expect(OPTIONS.sessionId).toBeDefined(); |
| 38 | + expect(OPTIONS.sessionId).not.toBe(firstSessionId); |
| 39 | + expect(server3.isRunning()).toBe(true); |
| 40 | + |
| 41 | + await server1.stop({ exitProcess: false }); |
| 42 | + await server2.stop({ exitProcess: false }); |
| 43 | + await server3.stop({ exitProcess: false }); |
| 44 | + }); |
| 45 | +}); |
| 46 | + |
| 47 | +/* |
11 | 48 | describe('Programmatic API Usage', () => { |
12 | 49 | let originalArgv: string[]; |
13 | 50 | let serverInstances: ServerInstance[] = []; |
@@ -324,3 +361,4 @@ describe('Programmatic API Usage', () => { |
324 | 361 | }); |
325 | 362 | }); |
326 | 363 | }); |
| 364 | +*/ |
0 commit comments