This commit is contained in:
2026-02-27 10:18:23 +00:00
commit 3f63d19173
36 changed files with 14285 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import { VpnClient } from '../ts/index.js';
import type { IVpnClientOptions } from '../ts/index.js';
let client: VpnClient;
tap.test('VpnClient: spawn daemon in stdio mode', async () => {
const options: IVpnClientOptions = {
transport: { transport: 'stdio' },
};
client = new VpnClient(options);
const started = await client.start();
expect(started).toBeTrue();
expect(client.running).toBeTrue();
});
tap.test('VpnClient: getStatus returns disconnected', async () => {
const status = await client.getStatus();
expect(status.state).toEqual('disconnected');
});
tap.test('VpnClient: getStatistics returns zeros', async () => {
const stats = await client.getStatistics();
expect(stats.bytesSent).toEqual(0);
expect(stats.bytesReceived).toEqual(0);
expect(stats.packetsSent).toEqual(0);
expect(stats.packetsReceived).toEqual(0);
});
tap.test('VpnClient: stop daemon', async () => {
client.stop();
// Give it a moment to clean up
await new Promise((resolve) => setTimeout(resolve, 500));
expect(client.running).toBeFalse();
});
export default tap.start();