Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { composerSuggestionOptionId } from "./ComposerCommandMenu";
4
5describe("composerSuggestionOptionId", () => {
6 it("keeps whitespace, escape-like paths, and malformed UTF-16 distinct", () => {
7 const paths = [
8 "docs/my file.md",
9 "docs/my_file.md",
10 "docs/my%20file.md",
11 "docs/my\tfile.md",
12 "docs/\ud800.md",
13 "docs/\ud801.md",
14 "docs/\udc00.md",
15 "docs/\ufffd.md",
16 "docs/\\ud800.md",
17 "docs/\ud83d\ude80.md",
18 ];
19 const ids = paths.map((path) => composerSuggestionOptionId("suggestions", `path:file:${path}`));
20
21 expect(new Set(ids).size).toBe(paths.length);
22 for (const id of ids) expect(id).not.toMatch(/\s|[\ud800-\udfff]/u);
23 expect(composerSuggestionOptionId("other-composer", paths[0]!)).not.toBe(
24 composerSuggestionOptionId("suggestions", paths[0]!),
25 );
26 });
27});