Files
Netcatty/domain/serialEndpoint.test.ts
T
陈大猫 43d714b73c feat(serial): support local Windows named pipe consoles (#3894)
* feat(serial): support local Windows named pipe consoles

* test(serial): synchronize pipe acceptance and cover saved-host form

* fix(serial): preserve named-pipe paths with spaces when editing hosts

* test(serial): verify Windows pipes through native Electron IPC

* test(serial): keep Electron listener callbacks in renderer context

* test(serial): cover busy pipe cancellation and bounded slow-reader writes

* test(serial): construct single-instance fixture pipe path correctly
2026-10-24 12:56:58 +08:00

22 lines
1.2 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import { isSerialEndpointPath, isWindowsNamedPipePath } from './serialEndpoint';
const require = createRequire(import.meta.url);
const backend = require('../electron/bridges/serialNamedPipe.cjs');
test('serial endpoint validation keeps hardware ports and accepts local Windows pipes', () => {
for (const value of ['/dev/ttyS0', '/dev/ttys001', 'COM1', String.raw`\\.\COM12`, String.raw`\\.\pipe\vm`, String.raw`\\?\pipe\vm`]) {
assert.equal(isSerialEndpointPath(value), true, value);
}
for (const value of ['', 'vm', '\\\\.\\pipe\\', String.raw`\\host\pipe\vm`]) {
assert.equal(isSerialEndpointPath(value), false, value);
}
});
test('renderer and backend agree on named pipe detection', () => {
for (const value of ['', '/dev/ttyS0', 'COM1', String.raw`\\.\COM1`, String.raw`\\.\pipe\vm`, String.raw`\\?\pipe\VM console`, String.raw`\\.\PIPE\vm\console`, String.raw`\\host\pipe\vm`, '\\\\.\\pipe\\', '\\\\.\\pipe\\vm\n', '\\\\.\\pipe\\vm\0']) {
assert.equal(isWindowsNamedPipePath(value), backend.isWindowsNamedPipePath(value), value);
}
});