b2fd06ed17
shared/tests/turn.jump.test.js: desired manual turn override behavior. - jump sets currentTurn, future nextTurn continues - jump to first stays same round - jump invalid throws 2 RED (shared.jumpTurnTo not a function - feature missing). 1 green (invalid throws via TypeError). TODO: JUMP_TURN_TO test refs added.
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
// JUMP_TURN_TO feature: DM clicks participant → turn jumps → future NEXT_TURN
|
|
// continues from jumped position. Missing feature, not bug.
|
|
// Test asserts desired behavior = RED (function doesn't exist).
|
|
|
|
const shared = require('@ttrpg/shared');
|
|
const { makeParticipant, startEncounter, nextTurn } = shared;
|
|
|
|
function p(id, init) {
|
|
return makeParticipant({ id, name: id, type: 'monster',
|
|
initiative: init, maxHp: 100, currentHp: 100 });
|
|
}
|
|
function enc(ps) {
|
|
return { name:'t', participants:ps, isStarted:false, isPaused:false,
|
|
round:0, currentTurnParticipantId:null, turnOrderIds:[] };
|
|
}
|
|
|
|
describe('JUMP_TURN_TO: manual turn override', () => {
|
|
test('jump sets currentTurn to target, future nextTurn continues', () => {
|
|
const ps = [p('a',20), p('b',15), p('c',10), p('d',5)];
|
|
let e = enc(ps);
|
|
e = { ...e, ...startEncounter(e).patch };
|
|
// current=a
|
|
e = { ...e, ...shared.jumpTurnTo(e, 'c').patch };
|
|
expect(e.currentTurnParticipantId).toBe('c');
|
|
// next turn continues from c → d
|
|
e = { ...e, ...nextTurn(e).patch };
|
|
expect(e.currentTurnParticipantId).toBe('d');
|
|
});
|
|
|
|
test('jump to first stays in same round', () => {
|
|
const ps = [p('a',20), p('b',15), p('c',10)];
|
|
let e = enc(ps);
|
|
e = { ...e, ...startEncounter(e).patch };
|
|
e = { ...e, ...nextTurn(e).patch }; // b
|
|
e = { ...e, ...shared.jumpTurnTo(e, 'a').patch };
|
|
expect(e.round).toBe(1);
|
|
expect(e.currentTurnParticipantId).toBe('a');
|
|
});
|
|
|
|
test('jump to invalid id throws', () => {
|
|
const ps = [p('a',20), p('b',15)];
|
|
let e = enc(ps);
|
|
e = { ...e, ...startEncounter(e).patch };
|
|
expect(() => shared.jumpTurnTo(e, 'zzz')).toThrow();
|
|
});
|
|
});
|