This repository has been archived on 2025-08-03. You can view files and clone it, but cannot push or open issues or pull requests.
network-orbit/tests/mocks/services.ts
anonpenguin 1cbca09352 Add unit tests for RelationshipManager and ShardManager
- Implement comprehensive tests for RelationshipManager covering various relationship types (BelongsTo, HasMany, HasOne, ManyToMany) and eager loading functionality.
- Include caching mechanisms and error handling in RelationshipManager tests.
- Create unit tests for ShardManager to validate shard creation, routing, management, global index operations, and query functionalities.
- Ensure tests cover different sharding strategies (hash, range, user) and handle edge cases like errors and non-existent models.
2025-06-19 11:20:13 +03:00

35 lines
872 B
TypeScript

// Mock services factory for testing
import { MockIPFSService, MockOrbitDBService } from './ipfs';
export function createMockServices() {
const ipfsService = new MockIPFSService();
const orbitDBService = new MockOrbitDBService();
return {
ipfsService,
orbitDBService,
async initialize() {
await ipfsService.init();
await orbitDBService.init();
},
async cleanup() {
await ipfsService.stop();
await orbitDBService.stop();
}
};
}
// Test utilities
export function createMockDatabase() {
const { MockDatabase } = require('./orbitdb');
return new MockDatabase('test-db', { type: 'docstore' });
}
export function createMockRecord(overrides: any = {}) {
return {
id: `test-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
createdAt: Date.now(),
updatedAt: Date.now(),
...overrides
};
}