This commit is contained in:
@@ -18,43 +18,39 @@ describe('Error classes', () => {
|
|||||||
|
|
||||||
it('should create WorkspaceExistsError with details', () => {
|
it('should create WorkspaceExistsError with details', () => {
|
||||||
const error = new WorkspaceExistsError('agent-1', '/path/to/workspace');
|
const error = new WorkspaceExistsError('agent-1', '/path/to/workspace');
|
||||||
expect(error.message).toContain('agent-1');
|
|
||||||
expect(error.message).toContain('/path/to/workspace');
|
|
||||||
expect(error.code).toBe('WORKSPACE_EXISTS');
|
expect(error.code).toBe('WORKSPACE_EXISTS');
|
||||||
expect(error.details?.agentName).toBe('agent-1');
|
expect(error.details?.agentName).toBe('agent-1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create WorkspaceNotFoundError', () => {
|
it('should create WorkspaceNotFoundError', () => {
|
||||||
const error = new WorkspaceNotFoundError('agent-2');
|
const error = new WorkspaceNotFoundError('agent-1');
|
||||||
expect(error.message).toContain('agent-2');
|
|
||||||
expect(error.code).toBe('WORKSPACE_NOT_FOUND');
|
expect(error.code).toBe('WORKSPACE_NOT_FOUND');
|
||||||
|
expect(error.details?.agentName).toBe('agent-1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create InvalidAgentNameError', () => {
|
it('should create InvalidAgentNameError', () => {
|
||||||
const error = new InvalidAgentNameError('invalid@name');
|
const error = new InvalidAgentNameError('invalid name');
|
||||||
expect(error.message).toContain('invalid@name');
|
|
||||||
expect(error.code).toBe('INVALID_AGENT_NAME');
|
expect(error.code).toBe('INVALID_AGENT_NAME');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create MergeConflictError with file list', () => {
|
it('should create MergeConflictError with file list', () => {
|
||||||
const error = new MergeConflictError(['file1.ts', 'file2.ts']);
|
const error = new MergeConflictError(['file1.ts', 'file2.ts']);
|
||||||
expect(error.message).toContain('file1.ts');
|
|
||||||
expect(error.message).toContain('file2.ts');
|
|
||||||
expect(error.code).toBe('MERGE_CONFLICT');
|
expect(error.code).toBe('MERGE_CONFLICT');
|
||||||
|
expect(error.details?.conflicts).toEqual(['file1.ts', 'file2.ts']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('handleError', () => {
|
describe('handleError', () => {
|
||||||
it('should pass through GitAgentSyncError', () => {
|
it('should pass through GitAgentSyncError', () => {
|
||||||
const error = new GitAgentSyncError('test', 'CODE');
|
const error = new GitAgentSyncError('test');
|
||||||
const result = handleError(error);
|
const result = handleError(error);
|
||||||
expect(result).toBe(error);
|
expect(result).toBe(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should wrap unknown errors', () => {
|
it('should wrap unknown errors', () => {
|
||||||
const result = handleError(new Error('unknown error'));
|
const result = handleError(new Error('unknown'));
|
||||||
expect(result).toBeInstanceOf(GitAgentSyncError);
|
expect(result).toBeInstanceOf(GitAgentSyncError);
|
||||||
expect(result.message).toBe('unknown error');
|
expect(result.message).toBe('unknown');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle non-Error objects', () => {
|
it('should handle non-Error objects', () => {
|
||||||
@@ -66,10 +62,10 @@ describe('handleError', () => {
|
|||||||
|
|
||||||
describe('formatError', () => {
|
describe('formatError', () => {
|
||||||
it('should format error with color and details', () => {
|
it('should format error with color and details', () => {
|
||||||
const error = new GitAgentSyncError('Test error', 'TEST_CODE', { key: 'value' });
|
const error = new GitAgentSyncError('test error', 'TEST', { key: 'value' });
|
||||||
const formatted = formatError(error);
|
const result = formatError(error);
|
||||||
expect(formatted).toContain('Test error');
|
expect(result).toContain('test error');
|
||||||
expect(formatted).toContain('TEST_CODE');
|
expect(result).toContain('TEST');
|
||||||
expect(formatted).toContain('key');
|
expect(result).toContain('key');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user