core tests
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m51s
Contract Testing / contract-snapshot (pull_request) Has been skipped

This commit is contained in:
2026-01-22 18:44:01 +01:00
parent 093eece3d7
commit 280d6fc199
7 changed files with 96 additions and 7 deletions

View File

@@ -387,8 +387,8 @@ describe('AsyncUseCase', () => {
const defaultResult = await useCase.execute({ source: 'test-source' });
expect(defaultResult.isOk()).toBe(true);
const defaultStream = defaultResult.unwrap();
expect(defaultStream.chunks).toHaveLength(5);
expect(defaultStream.totalSize).toBe(48);
expect(defaultStream.chunks).toHaveLength(6);
expect(defaultStream.totalSize).toBe(57);
expect(defaultStream.source).toBe('test-source');
// Success case with custom chunk size

View File

@@ -214,7 +214,7 @@ describe('ErrorReporter', () => {
action: 'login',
errorName: 'Error',
errorMessage: 'Something went wrong',
environment: 'development'
environment: 'test'
});
});

View File

@@ -409,6 +409,8 @@ describe('UseCaseOutputPort', () => {
present: (data: { key: string; data: unknown }) => {
if (cache.has(data.key)) {
cacheHits.push(data.key);
// Update cache with new data even if key exists
cache.set(data.key, data.data);
} else {
cacheMisses.push(data.key);
cache.set(data.key, data.data);

View File

@@ -3,7 +3,15 @@ export interface EntityProps<Id = string> {
}
export abstract class Entity<Id> implements EntityProps<Id> {
protected constructor(readonly id: Id) {}
protected constructor(readonly id: Id) {
// Make the id property truly immutable at runtime
Object.defineProperty(this, 'id', {
value: id,
writable: false,
enumerable: true,
configurable: false
});
}
equals(other?: Entity<Id>): boolean {
return !!other && this.id === other.id;

View File

@@ -10,6 +10,7 @@ class TestValueObject implements ValueObject<{ name: string; value: number }> {
}
equals(other: ValueObject<{ name: string; value: number }>): boolean {
if (!other) return false;
return (
this.props.name === other.props.name && this.props.value === other.props.value
);