|
| 1 | +import { describe, it, expect, beforeEach, afterEach } from 'vitest'; |
| 2 | +import { getDefaultDebuggerManager } from '../../../utils/debugger/index.ts'; |
| 3 | +import { activeLogSessions } from '../../../utils/log_capture.ts'; |
| 4 | +import { activeDeviceLogSessions } from '../../../utils/log-capture/device-log-sessions.ts'; |
| 5 | +import sessionStatusResource, { sessionStatusResourceLogic } from '../session-status.ts'; |
| 6 | + |
| 7 | +describe('session-status resource', () => { |
| 8 | + beforeEach(async () => { |
| 9 | + activeLogSessions.clear(); |
| 10 | + activeDeviceLogSessions.clear(); |
| 11 | + await getDefaultDebuggerManager().disposeAll(); |
| 12 | + }); |
| 13 | + |
| 14 | + afterEach(async () => { |
| 15 | + activeLogSessions.clear(); |
| 16 | + activeDeviceLogSessions.clear(); |
| 17 | + await getDefaultDebuggerManager().disposeAll(); |
| 18 | + }); |
| 19 | + |
| 20 | + describe('Export Field Validation', () => { |
| 21 | + it('should export correct uri', () => { |
| 22 | + expect(sessionStatusResource.uri).toBe('xcodebuildmcp://session-status'); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should export correct description', () => { |
| 26 | + expect(sessionStatusResource.description).toBe( |
| 27 | + 'Runtime session state for log capture and debugging', |
| 28 | + ); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should export correct mimeType', () => { |
| 32 | + expect(sessionStatusResource.mimeType).toBe('text/plain'); |
| 33 | + }); |
| 34 | + |
| 35 | + it('should export handler function', () => { |
| 36 | + expect(typeof sessionStatusResource.handler).toBe('function'); |
| 37 | + }); |
| 38 | + }); |
| 39 | + |
| 40 | + describe('Handler Functionality', () => { |
| 41 | + it('should return empty status when no sessions exist', async () => { |
| 42 | + const result = await sessionStatusResourceLogic(); |
| 43 | + |
| 44 | + expect(result.contents).toHaveLength(1); |
| 45 | + const parsed = JSON.parse(result.contents[0].text); |
| 46 | + |
| 47 | + expect(parsed.logging.simulator.activeSessionIds).toEqual([]); |
| 48 | + expect(parsed.logging.device.activeSessionIds).toEqual([]); |
| 49 | + expect(parsed.debug.currentSessionId).toBe(null); |
| 50 | + expect(parsed.debug.sessionIds).toEqual([]); |
| 51 | + }); |
| 52 | + }); |
| 53 | +}); |
0 commit comments