muse-agent-example/web/tests/编辑/选区转换.test.ts
zizi ae02fd1732 前端:工作台页面、事件标签与旅程用例
- 上下文清单、任务列表与详情、恢复控制、运行观察、创作对话与消息流、正式变更决策面板、正文写作与候选审阅、资料研究等页面同步本轮后端能力。
- 事件标签表补齐后端事件类型;查询键与生成客户端随 HTTP 契约重新生成。
- 依赖调整后 lockfile 同步;交互用例与浏览器旅程 spec 一并更新。
- 证据:make 前端检查(lint + typecheck + Pi 工具桥 tsc)exit 0;make 前端测试 37 文件 / 120 用例通过。
2026-09-18 01:15:07 +08:00

13 lines
898 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { expect, it } from "vitest";
import { 码点到UTF16, UTF16到码点 } from "../../src/界面/编辑器/字符位置";
// @muse-case {"case_id":"NC-editor-codepoint-selection","environment":"离线组件/实际编辑器;HTTP响应替身不计真实链路","given":"emoji代理对和组合字符","when":"转换编辑器位置与码点位置","then":["合法位置可逆,不截断代理对"],"contract":"docs/系统架构/新版设计/接口契约/正文结构与中文选区.md"}
it("NC-editor-codepoint-selection:组合字符与代理对选区转换可逆", () => {
const text = "甲🧑‍🏽e\u0301乙";
for (let i = 0; i <= Array.from(text).length; i++) {
expect(UTF16到码点(text, 码点到UTF16(text, i))).toBe(i);
}
expect(() => UTF16到码点(text, 2)).toThrow();
expect(text.slice(码点到UTF16(text, 1), 码点到UTF16(text, 4))).toBe("🧑‍🏽");
});