The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { keepOrder, withArrivedKeys } from "./useOrderWhileOpen"; |
| 4 | |
| 5 | describe("keepOrder", () => { |
| 6 | it("keeps the opening order and puts new items after it", () => { |
| 7 | const key = (item: string) => item; |
| 8 | // "c" was pinned and moved to the top; "d" arrived after the list opened; "b" is gone. |
| 9 | expect(keepOrder(["c", "d", "a"], ["a", "b", "c"], key)).toEqual(["a", "c", "d"]); |
| 10 | expect(keepOrder(["c", "a"], null, key)).toEqual(["c", "a"]); |
| 11 | }); |
| 12 | |
| 13 | it("holds rows that arrived after opening in their first place", () => { |
| 14 | // "b" and "c" load from another machine after the list opened with nothing in it. |
| 15 | const order = withArrivedKeys(null, ["b", "c"]); |
| 16 | expect(order).toEqual(["b", "c"]); |
| 17 | // Pinning "c" moves it first in the source list; the shown order stays. |
| 18 | expect(keepOrder(["c", "b"], order, (item) => item)).toEqual(["b", "c"]); |
| 19 | expect(withArrivedKeys(order, ["b", "c"])).toBe(order); |
| 20 | }); |
| 21 | }); |