Elffuss BraidHub

kikocis/continue public

3ff29c567dd0 · 1.4 KiBRawPermalink
1import { SlashCommandDescWithSource } from "core";
2import { sortCommandsByBookmarkStatus } from "../utils";
3
4describe("sortCommandsByBookmarkStatus", () => {
5 const mockCommands: SlashCommandDescWithSource[] = [
6 {
7 name: "command1",
8 description: "First command",
9 prompt: "This is command 1",
10 source: "built-in",
11 isLegacy: false,
12 },
13 {
14 name: "command2",
15 description: "Second command",
16 prompt: "This is command 2",
17 source: "built-in",
18 isLegacy: false,
19 },
20 {
21 name: "command3",
22 description: "Third command",
23 prompt: "This is command 3",
24 source: "built-in",
25 isLegacy: false,
26 },
27 {
28 name: "command4",
29 description: "Fourth command",
30 prompt: "This is command 4",
31 source: "built-in",
32 isLegacy: false,
33 },
34 ];
35
36 it("should return commands in the same order when no bookmarks exist", () => {
37 const result = sortCommandsByBookmarkStatus(mockCommands, []);
38 expect(result).toEqual(mockCommands);
39 // Ensure it's a new array, not the original
40 expect(result).not.toBe(mockCommands);
41 });
42
43 it("should put bookmarked commands first", () => {
44 const bookmarkedCommands = ["command3", "command1"];
45 const result = sortCommandsByBookmarkStatus(
46 mockCommands,
47 bookmarkedCommands,
48 );
49
50 expect(result[0].name).toBe("command1");
51 expect(result[1].name).toBe("command3");
52 });
53});