Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Bell Tower peal-length page test is slow (≈4.5 s) and needed a 30 s budget #122
Check · Review · Land · Live done — Landed and live in production.
vesper/pixel-plays:vesper/113-bell-tower-peal-length-page-test-is-slow → main 1 commit fork
1 file
changed +7
−4
bell-tower/page.test.mjs +7 −4
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { test, expect } from 'bun:test'; |
| 2 | 2 | import { boot } from '../playtest.mjs'; |
| 3 | import { SWING } from './peal.js'; | |
| 3 | 4 | |
| 4 | 5 | // ring the tower's peal back by tapping the rope columns (the four bells sit at x = 45, 135, 225, 315) |
| 5 | 6 | const state = g => g.read('P'); |
| @@ -7,13 +8,15 @@ function untilTurn(g) { for (let n = 0; state(g).phase !== 'ring' && n < 400; n+ | ||
| 7 | 8 | |
| 8 | 9 | test('the HUD peal length follows the peal the tower is ringing', () => { |
| 9 | 10 | const g = boot('bell-tower'); |
| 10 | g.run(1); | |
| 11 | 11 | untilTurn(g); |
| 12 | 12 | expect(String(g.el('length').textContent)).toBe('3'); |
| 13 | for (const bell of [...state(g).seq]) { g.tap(45 + bell * 90, 150); g.run(.6); } | |
| 13 | // a bell cannot be pulled again while it swings, so wait only when the next bell is the one just rung | |
| 14 | let last = -1; | |
| 15 | for (const bell of [...state(g).seq]) { if (bell === last) g.run(SWING); g.tap(45 + bell * 90, 150); last = bell; } | |
| 14 | 16 | expect(String(g.el('score').textContent)).toBe('3'); |
| 15 | untilTurn(g); | |
| 17 | // the HUD shows the longer peal as the tower starts it, not only once it is the player's turn again | |
| 18 | for (let n = 0; state(g).phase !== 'listen' && n < 400; n++) g.run(.05); | |
| 16 | 19 | expect(state(g).seq.length).toBe(4); |
| 17 | 20 | expect(String(g.el('length').textContent)).toBe('4'); |
| 18 | 21 | expect(g.errors).toEqual([]); |
| 19 | }, 30000); | |
| 22 | }); |
new above
offline