import { DyNTS_ServerStatusSnapshot_ControlService } from './server-status-snapshot.control-service'; import { DyFM_ServerStatus } from '@futdevpro/fsm-dynamo'; class TestServerStatus extends DyFM_ServerStatus { constructor(set?: Partial) { super(); Object.assign(this, set); } } class TestServerStatusSnapshotControlService extends DyNTS_ServerStatusSnapshot_ControlService { async saveSnapshot(snapshot: TestServerStatus, issuer: string): Promise { return snapshot; } static getInstance(): TestServerStatusSnapshotControlService { return (TestServerStatusSnapshotControlService as any).getSingletonInstance(); } } describe('| DyNTS_ServerStatusSnapshot_ControlService', () => { let service: TestServerStatusSnapshotControlService; beforeEach(() => { service = new TestServerStatusSnapshotControlService(); }); describe('| constructor', () => { it('| should create instance', () => { expect(service).toBeDefined(); expect(service).toBeInstanceOf(TestServerStatusSnapshotControlService); }); }); describe('| saveSnapshot', () => { it('| should save snapshot', async () => { const snapshot: TestServerStatus = new TestServerStatus({ status: 'ready', systemName: 'Test System', }); const result = await service.saveSnapshot(snapshot, 'test-issuer'); expect(result).toBeDefined(); expect(result.status).toBe('ready'); expect(result.systemName).toBe('Test System'); }); it('| should handle snapshot with all properties', async () => { const snapshot: TestServerStatus = new TestServerStatus({ status: 'ready', systemName: 'Test System', systemShortCode: 'TEST', uptime: 1000, memoryUsage: process.memoryUsage(), cpuUsage: process.cpuUsage(), }); const result = await service.saveSnapshot(snapshot, 'test-issuer'); expect(result).toBeDefined(); expect(result.status).toBe('ready'); expect(result.systemName).toBe('Test System'); expect(result.systemShortCode).toBe('TEST'); expect(result.uptime).toBe(1000); }); }); });