code quality
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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';
|
||||
@@ -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' }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user