|
886 | 886 | }); |
887 | 887 | }); |
888 | 888 |
|
| 889 | + describe("pointer events", () => { |
| 890 | + let siblings: Op[] = [ |
| 891 | + open("root", { |
| 892 | + layout: { width: grow(), height: grow(), direction: "ltr" }, |
| 893 | + }), |
| 894 | + open("left", { layout: { width: fixed(20), height: grow() } }), |
| 895 | + close(), |
| 896 | + open("right", { layout: { width: fixed(20), height: grow() } }), |
| 897 | + close(), |
| 898 | + close(), |
| 899 | + ]; |
| 900 | + |
| 901 | + let rows: Op[] = [ |
| 902 | + open("root", { |
| 903 | + layout: { width: grow(), height: grow(), direction: "ttb" }, |
| 904 | + }), |
| 905 | + open("row0", { layout: { width: grow(), height: fixed(1) } }), |
| 906 | + close(), |
| 907 | + open("row1", { layout: { width: grow(), height: fixed(1) } }), |
| 908 | + close(), |
| 909 | + close(), |
| 910 | + ]; |
| 911 | + |
| 912 | + function click(frame: Op[], x: number, y: number): string[] { |
| 913 | + term.render(frame, { pointer: { x, y, down: true } }); |
| 914 | + return term.render(frame, { pointer: { x, y, down: false } }).events |
| 915 | + .filter((event) => event.type === "pointerclick") |
| 916 | + .map((event) => event.id); |
| 917 | + } |
| 918 | + |
| 919 | + it("clicks only the sibling that owns the first cell past a shared edge", () => { |
| 920 | + let ids = click(siblings, 20, 0); |
| 921 | + expect(ids).toContain("right"); |
| 922 | + expect(ids).not.toContain("left"); |
| 923 | + }); |
| 924 | + |
| 925 | + it("clicks only the row that owns the first row past a shared edge", () => { |
| 926 | + let ids = click(rows, 0, 1); |
| 927 | + expect(ids).toContain("row1"); |
| 928 | + expect(ids).not.toContain("row0"); |
| 929 | + }); |
| 930 | + |
| 931 | + it("reports no element for a pointer past the last column", () => { |
| 932 | + expect(click(siblings, 40, 0)).toEqual([]); |
| 933 | + }); |
| 934 | + }); |
| 935 | + |
889 | 936 | describe("synchronized output", () => { |
890 | 937 | let frame: Op[] = [ |
891 | 938 | open("root", { layout: { width: grow(), height: grow() } }), |
|
0 commit comments