Files
TamaASR/test/fcitx-bridge.test.ts
T
MeloriseandCodex 2100ebab6b feat: rename project to TamaASR 1.0.0
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>
2026-09-01 20:55:14 +08:00

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);
});