code quality

This commit is contained in:
2026-01-26 01:36:22 +01:00
parent f06a00da1b
commit 49cc91e046
23 changed files with 68 additions and 54 deletions

View File

@@ -294,7 +294,7 @@ describe('Result', () => {
it('should stop chaining on first error', () => {
const result = Result.ok(2)
.andThen((x) => Result.ok(x * 3))
.andThen((x) => Result.err(new Error('stopped here')))
.andThen((x) => Result.err(new Error(`stopped at ${x}`)))
.andThen((x) => Result.ok(x + 1)); // This should not execute
expect(result.isErr()).toBe(true);

View File

@@ -36,14 +36,14 @@ describe('ValueObject', () => {
it('should return false when comparing with undefined', () => {
const vo = new TestValueObject('test', 42);
// Testing that equals method handles undefined gracefully
const result = vo.equals as any;
const result = vo.equals as (other: unknown) => boolean;
expect(result(undefined)).toBe(false);
});
it('should return false when comparing with null', () => {
const vo = new TestValueObject('test', 42);
// Testing that equals method handles null gracefully
const result = vo.equals as any;
const result = vo.equals as (other: unknown) => boolean;
expect(result(null)).toBe(false);
});
});

View File

@@ -1,7 +0,0 @@
export * from './DomainEvent';
export * from './Entity';
export * from './Logger';
export * from './Option';
export * from './Result';
export * from './Service';
export * from './ValueObject';

View File

@@ -92,16 +92,16 @@ describe('ApplicationErrorCode', () => {
// This test verifies the type compatibility
type MyErrorCodes = 'USER_NOT_FOUND' | 'VALIDATION_ERROR' | 'PERMISSION_DENIED';
const userNotFound: ApplicationErrorCode<'USER_NOT_FOUND'> = {
const userNotFound: ApplicationErrorCode<MyErrorCodes> = {
code: 'USER_NOT_FOUND'
};
const validationError: ApplicationErrorCode<'VALIDATION_ERROR', { field: string }> = {
const validationError: ApplicationErrorCode<MyErrorCodes, { field: string }> = {
code: 'VALIDATION_ERROR',
details: { field: 'email' }
};
const permissionError: ApplicationErrorCode<'PERMISSION_DENIED', { resource: string }> = {
const permissionError: ApplicationErrorCode<MyErrorCodes, { resource: string }> = {
code: 'PERMISSION_DENIED',
details: { resource: 'admin-panel' }
};