| | |
| | |
| | |
| | |
| | |
| |
|
| | import { vi, describe, it, expect } from 'vitest'; |
| | import { createMockCommandContext } from './mockCommandContext.js'; |
| |
|
| | describe('createMockCommandContext', () => { |
| | it('should return a valid CommandContext object with default mocks', () => { |
| | const context = createMockCommandContext(); |
| |
|
| | |
| | |
| | expect(context).toBeDefined(); |
| | expect(context.ui.addItem).toBeInstanceOf(Function); |
| | expect(vi.isMockFunction(context.ui.addItem)).toBe(true); |
| | }); |
| |
|
| | it('should apply top-level overrides correctly', () => { |
| | const mockClear = vi.fn(); |
| | const overrides = { |
| | ui: { |
| | clear: mockClear, |
| | }, |
| | }; |
| |
|
| | const context = createMockCommandContext(overrides); |
| |
|
| | |
| | context.ui.clear(); |
| |
|
| | |
| | expect(mockClear).toHaveBeenCalled(); |
| | |
| | expect(vi.isMockFunction(context.ui.addItem)).toBe(true); |
| | }); |
| |
|
| | it('should apply deeply nested overrides correctly', () => { |
| | |
| | const mockConfig = { |
| | getProjectRoot: () => '/test/project', |
| | getModel: () => 'gemini-pro', |
| | }; |
| |
|
| | const overrides = { |
| | services: { |
| | config: mockConfig, |
| | }, |
| | }; |
| |
|
| | const context = createMockCommandContext(overrides); |
| |
|
| | expect(context.services.config).toBeDefined(); |
| | expect(context.services.config?.getModel()).toBe('gemini-pro'); |
| | expect(context.services.config?.getProjectRoot()).toBe('/test/project'); |
| |
|
| | |
| | expect(context.services.logger).toBeDefined(); |
| | }); |
| | }); |
| |
|