Initial commit: CraftDock as of 2026-11-01

The previous GitHub history was lost with the account (the local .git was missing
its refs and most objects), so this repository starts from the existing code.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Sonnet 5.5 committed 2026-11-01 22:44:39 -03:00
commit 640e52c0c9
99 files changed
+12115

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import { describe, it, expect, vi } from 'vitest';
import { createRconService, RconUnavailableError } from '../../src/services/rconService.js';
function fakeRconClass({ failConnect = false } = {}) {
return class {
static async connect() {
if (failConnect) throw new Error('ECONNREFUSED');
return {
send: vi.fn().mockResolvedValue('command output'),
end: vi.fn().mockResolvedValue(),
on: vi.fn(),
};
}
};
}
const config = { rconHost: 'h', rconPort: 25575, rconPassword: 'p' };
describe('rconService', () => {
it('connects lazily and sends a command', async () => {
const svc = createRconService(config, fakeRconClass());
const out = await svc.send('list');
expect(out).toBe('command output');
});
it('throws RconUnavailableError when connect fails', async () => {
const svc = createRconService(config, fakeRconClass({ failConnect: true }));
await expect(svc.send('list')).rejects.toBeInstanceOf(RconUnavailableError);
});
});