40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
const componentPath = resolve(
|
|
scriptDir,
|
|
"../src/pages/ChatMain/ChatInputArea/index.vue"
|
|
);
|
|
const source = readFileSync(componentPath, "utf8");
|
|
|
|
const handlerMatch = source.match(
|
|
/const\s+handleVoiceTouchEndFromContainer\s*=\s*\(\)\s*=>\s*{([\s\S]*?)\n};/
|
|
);
|
|
|
|
assert.ok(
|
|
handlerMatch,
|
|
"ChatInputArea should define handleVoiceTouchEndFromContainer"
|
|
);
|
|
|
|
const handlerBody = handlerMatch[1];
|
|
|
|
assert.ok(
|
|
!/speechProvider\s*!==\s*["']app["']/.test(handlerBody),
|
|
"container touchend must not ignore WeChat recordings because the pressed button can unmount while RecordingWaveBtn is shown"
|
|
);
|
|
|
|
assert.ok(
|
|
/hasActiveVoiceRecognition\(\)/.test(handlerBody),
|
|
"container touchend should only stop when a voice recognition session is active"
|
|
);
|
|
|
|
assert.ok(
|
|
/stopActiveVoiceRecognition\(\{\s*shouldSend:\s*true\s*\}\)/s.test(
|
|
handlerBody
|
|
),
|
|
"container touchend should stop the active recognition and send recognized text"
|
|
);
|