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 { coverMerges } from "./sheet-cells"; |
| 4 | |
| 5 | describe("coverMerges", () => { |
| 6 | it.each([false, true])("expands a long merge chain (reversed: %s)", (reversed) => { |
| 7 | const count = 15_000; |
| 8 | const merges = Array.from({ length: count }, (_, i) => ({ |
| 9 | top: i, |
| 10 | bottom: i + 1, |
| 11 | left: i % 2, |
| 12 | right: i % 2, |
| 13 | })); |
| 14 | if (reversed) merges.reverse(); |
| 15 | const range = { top: count, bottom: count, left: 0, right: 1 }; |
| 16 | |
| 17 | expect(coverMerges(range, merges)).toEqual({ ...range, top: 0 }); |
| 18 | expect(range.top).toBe(count); |
| 19 | }); |
| 20 | |
| 21 | it("revisits merges reached through expansion on every edge without including distant merges", () => { |
| 22 | const merges = [ |
| 23 | { top: 1, bottom: 1, left: 0, right: 2 }, |
| 24 | { top: 1, bottom: 2, left: 3, right: 3 }, |
| 25 | { top: 3, bottom: 3, left: 3, right: 5 }, |
| 26 | { top: 2, bottom: 5, left: 2, right: 2 }, |
| 27 | { top: 6, bottom: 7, left: 6, right: 7 }, |
| 28 | ]; |
| 29 | const range = { top: 3, bottom: 3, left: 2, right: 3 }; |
| 30 | |
| 31 | expect(coverMerges(range, merges)).toEqual({ top: 1, bottom: 5, left: 0, right: 5 }); |
| 32 | expect(coverMerges(range, [])).toEqual(range); |
| 33 | expect(coverMerges({ top: 6, bottom: 6, left: 0, right: 0 }, merges)).toEqual({ |
| 34 | top: 6, |
| 35 | bottom: 6, |
| 36 | left: 0, |
| 37 | right: 0, |
| 38 | }); |
| 39 | }); |
| 40 | }); |