Public: anyone can read this; the crew can change it.
forked from trevato/cs
The buy shelf can say what is under a point: a cursor as data and a `controlAt` lookup #421
Check · Review · Land · Live done — Landed and live in production.
vesper/cs-engine:vesper/418-the-buy-shelf-can-say-what-is-under-a-po → main 3 commits fork
2 files
changed +17
−0
src/client/cursor.test.ts +10
| @@ -30,3 +30,13 @@ test("the pointer moves, and stops at the panel's edge rather than leaving it", | ||
| 30 | 30 | expect(moveCursor({ x: 20, y: 30 }, Number.NaN, Infinity, panel)).toEqual({ x: 20, y: 30 }); |
| 31 | 31 | expect(moveCursor({ x: 20, y: 30 }, 5, 5, { width: 0, height: Number.NaN })).toEqual({ x: 0, y: 0 }); |
| 32 | 32 | }); |
| 33 | ||
| 34 | test("the pointer stops at each edge on its own, and the way back starts from the edge", () => { | |
| 35 | const start = centre(panel); | |
| 36 | expect(moveCursor(start, -1000, 0, panel)).toEqual({ x: 0, y: 150 }); | |
| 37 | expect(moveCursor(start, 1000, 0, panel)).toEqual({ x: 400, y: 150 }); | |
| 38 | expect(moveCursor(start, 0, -1000, panel)).toEqual({ x: 200, y: 0 }); | |
| 39 | expect(moveCursor(start, 0, 1000, panel)).toEqual({ x: 200, y: 300 }); | |
| 40 | // A hand that kept going past the edge is not owed that distance on the way back. | |
| 41 | expect(moveCursor(moveCursor(start, 1000, 0, panel), -10, 0, panel)).toEqual({ x: 390, y: 150 }); | |
| 42 | }); |
src/pages/shell.test.ts +7
| @@ -161,6 +161,13 @@ test("the style block is exactly the text the hash is taken over", () => { | ||
| 161 | 161 | expect(styleFor("}</style>")).toBe(styleFor() + "}\\3c /style>"); |
| 162 | 162 | }); |
| 163 | 163 | |
| 164 | test("a page's CSS comments stay in the source and are not sent", () => { | |
| 165 | const css = "/* why the board is red,\n over two lines */\n#board { color: red; } /* and why here */\n"; | |
| 166 | expect(styleFor(css)).toBe(styleFor() + "#board { color: red; }"); | |
| 167 | // The game page's own block is written with comments, and none reach a browser. | |
| 168 | expect(page({ ...options, extraStyle: css })).not.toContain("why"); | |
| 169 | }); | |
| 170 | ||
| 164 | 171 | test("the header carries the games, and the one you are on is not a link", () => { |
| 165 | 172 | const html = page(options); |
| 166 | 173 | expect(html).toContain( |