AI Implementation feature(820): Project Scaffold and Platform Foundations (#1)
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { ApiError } from '../../backend/src/common/errors/api-error';
|
||||
import { ERROR_CODES } from '../../backend/src/common/errors/error-codes';
|
||||
|
||||
describe('ApiError', () => {
|
||||
it('formats validation errors with details', () => {
|
||||
const e = ApiError.validation('Bad input', { field: 'x' });
|
||||
expect(e.getStatus()).toBe(400);
|
||||
const body = e.getResponse() as any;
|
||||
expect(body.code).toBe(ERROR_CODES.VALIDATION_FAILED);
|
||||
expect(body.message).toBe('Bad input');
|
||||
expect(body.details).toEqual({ field: 'x' });
|
||||
});
|
||||
|
||||
it('formats last-admin conflict', () => {
|
||||
const e = ApiError.conflict(ERROR_CODES.LAST_ADMIN, 'Cannot delete the last admin');
|
||||
expect(e.getStatus()).toBe(409);
|
||||
const body = e.getResponse() as any;
|
||||
expect(body.code).toBe(ERROR_CODES.LAST_ADMIN);
|
||||
});
|
||||
|
||||
it('formats internal error as 500', () => {
|
||||
const e = ApiError.internal();
|
||||
expect(e.getStatus()).toBe(500);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user