mirror of
https://github.com/Melorise/TamaASR.git
synced 2026-11-07 14:39:32 +00:00
Migrate internal identifiers, installation paths, packaging metadata, and repository references while preserving package upgrades from meloasr. AI-assisted-by: Codex AI-model: gpt-5.6-sol AI-reasoning-effort: medium Co-authored-by: Codex <codex@openai.com>
19 lines
874 B
TypeScript
19 lines
874 B
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { JsonLineDecoder, defaultSocketPath } from '../src/main/fcitx-bridge';
|
|
|
|
test('Socket 路径只使用当前用户运行时目录', () => {
|
|
assert.equal(defaultSocketPath({ XDG_RUNTIME_DIR: '/run/user/1000' }), '/run/user/1000/tama-asr/fcitx5.sock');
|
|
assert.throws(() => defaultSocketPath({}), /XDG_RUNTIME_DIR/);
|
|
});
|
|
|
|
test('JSONL 解码器支持拆包、粘包与无效 JSON', () => {
|
|
const messages: unknown[] = [];
|
|
const errors: Error[] = [];
|
|
const decoder = new JsonLineDecoder((message) => messages.push(message), (error) => errors.push(error));
|
|
decoder.push('{"type":"hel');
|
|
decoder.push('lo","protocol":2}\n{"type":"request-start"}\nnot-json\n');
|
|
assert.deepEqual(messages, [{ type: 'hello', protocol: 2 }, { type: 'request-start' }]);
|
|
assert.equal(errors.length, 1);
|
|
});
|