Add HUD and collision wiring tests
This commit is contained in:
parent
9e24a5e1e1
commit
c8f7fa1e1a
49
tests/wiring.test.mjs
Normal file
49
tests/wiring.test.mjs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { readFile } from 'node:fs/promises';
|
||||||
|
|
||||||
|
const read = (path) => readFile(new URL(`../${path}`, import.meta.url), 'utf8');
|
||||||
|
|
||||||
|
test('mobile HUD uses split helm frame and knob assets', async () => {
|
||||||
|
const source = await read('src/mobile-hud.js');
|
||||||
|
|
||||||
|
assert.match(source, /import helmFrameSrc from '.\/assets\/controller\/helm-frame\.js'/);
|
||||||
|
assert.match(source, /import helmKnobSrc from '.\/assets\/controller\/helm-knob\.js'/);
|
||||||
|
assert.doesNotMatch(source, /helmSpriteSheetSrc/);
|
||||||
|
assert.doesNotMatch(source, /helm-sheet\.webp/);
|
||||||
|
assert.doesNotMatch(source, /backgroundPosition = .*column/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('drag control emits and HUD consumes one shared helm vector event', async () => {
|
||||||
|
const [index, hud] = await Promise.all([
|
||||||
|
read('index.html'),
|
||||||
|
read('src/mobile-hud.js'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert.match(index, /CustomEvent\('airship:helm-vector'/);
|
||||||
|
assert.match(index, /emitHelmVector\(dx \/ radius, dy \/ radius\)/);
|
||||||
|
assert.match(index, /emitHelmVector\(0, 0\)/);
|
||||||
|
|
||||||
|
assert.match(hud, /addEventListener\('airship:helm-vector'/);
|
||||||
|
assert.match(hud, /setHelmKnob\(event\.detail\?\.x \?\? 0, event\.detail\?\.y \?\? 0\)/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('top HUD and cannon controls use direct image modules', async () => {
|
||||||
|
const source = await read('src/mobile-hud.js');
|
||||||
|
|
||||||
|
assert.match(source, /import topHudSrc from '.\/assets\/controller\/top-hud\.js'/);
|
||||||
|
assert.match(source, /import cannonRoundelSrc from '.\/assets\/controller\/cannon-roundel\.js'/);
|
||||||
|
assert.match(source, /addPiece\('steam-top', topHudSrc/);
|
||||||
|
assert.match(source, /addPiece\('steam-cannon-port', cannonRoundelSrc/);
|
||||||
|
assert.match(source, /addPiece\('steam-cannon-starboard', cannonRoundelSrc/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('player collision callback queues hits and processing occurs in scene update', async () => {
|
||||||
|
const source = await read('src/game-v4.js');
|
||||||
|
|
||||||
|
assert.match(source, /this\.pendingPlayerHits\.push\(\{ shot, damage \}\)/);
|
||||||
|
assert.match(source, /this\.processPlayerHits\(\)/);
|
||||||
|
assert.match(source, /reducePlayerHitQueue\(\{/);
|
||||||
|
assert.match(source, /combat:player-hit-queued/);
|
||||||
|
assert.match(source, /combat:player-hit-processed/);
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user