test(gameState): copri i branch residui di nuovoSet/confermaCambi/resetta/startTimeout

Aggiunge casi per team 'guest' in nuovoSet, cambi senza array
`cambi`, resetta con striscia vuota e startTimeout senza startedAt:
gameState.js passa dal 100% al 100% statement ma sale al 99% branch.
This commit is contained in:
2026-07-03 11:59:17 +02:00
parent 5bdd8ad986
commit fdd1d0c990
+25
View File
@@ -365,6 +365,13 @@ describe('Game Logic (gameState.js)', () => {
expect(setDi(s).guest).toBe(0) expect(setDi(s).guest).toBe(0)
}) })
it('dovrebbe incrementare il set guest e servire guest nel nuovo set', () => {
const s = applyAction(state, { type: 'nuovoSet', team: 'guest' })
expect(setDi(s).home).toBe(0)
expect(setDi(s).guest).toBe(1)
expect(s.sp.striscia.at(-1).serv).toBe('g')
})
it('in 2/3 alla palla match registra il set vincente senza aprirne uno nuovo', () => { it('in 2/3 alla palla match registra il set vincente senza aprirne uno nuovo', () => {
state.modalitaPartita = '2/3' state.modalitaPartita = '2/3'
setSetVinti(state, 1, 0) setSetVinti(state, 1, 0)
@@ -508,6 +515,12 @@ describe('Game Logic (gameState.js)', () => {
expect(s.timeoutVideo).toBe(null) expect(s.timeoutVideo).toBe(null)
}) })
it('startTimeout senza startedAt dovrebbe lasciare timeoutStartedAt null', () => {
const s = applyAction(state, { type: 'startTimeout', team: 'home', video: 'spot.mp4' })
expect(s.timeout).toBe(true)
expect(s.timeoutStartedAt).toBe(null)
})
it('startTimeout senza squadra valida dovrebbe essere ignorato', () => { it('startTimeout senza squadra valida dovrebbe essere ignorato', () => {
for (const team of [undefined, null, 'arbitro', '']) { for (const team of [undefined, null, 'arbitro', '']) {
const s = applyAction(state, { type: 'startTimeout', team, video: 'spot.mp4', startedAt: 1000 }) const s = applyAction(state, { type: 'startTimeout', team, video: 'spot.mp4', startedAt: 1000 })
@@ -644,6 +657,12 @@ describe('Game Logic (gameState.js)', () => {
// CAMBI GIOCATORI (confermaCambi) // CAMBI GIOCATORI (confermaCambi)
// ============================================= // =============================================
describe('confermaCambi', () => { describe('confermaCambi', () => {
it('senza array cambi non dovrebbe modificare la formazione', () => {
state.sp.form.home = ["1", "2", "3", "4", "5", "6"]
const s = applyAction(state, { type: 'confermaCambi', team: 'home' })
expect(s.sp.form.home).toEqual(["1", "2", "3", "4", "5", "6"])
})
it('dovrebbe effettuare una sostituzione valida', () => { it('dovrebbe effettuare una sostituzione valida', () => {
state.sp.form.home = ["1", "2", "3", "4", "5", "6"] state.sp.form.home = ["1", "2", "3", "4", "5", "6"]
const s = applyAction(state, { const s = applyAction(state, {
@@ -941,6 +960,12 @@ describe('Game Logic (gameState.js)', () => {
expect(s.sp.striscia[0].ris).toBe('') expect(s.sp.striscia[0].ris).toBe('')
}) })
it('con striscia vuota dovrebbe usare "h" come servizio iniziale di default', () => {
state.sp.striscia = []
const s = applyAction(state, { type: 'resetta' })
expect(s.sp.striscia).toEqual([{ serv: 'h', ris: '', vinc: null }])
})
it('dovrebbe impostare visuForm a false', () => { it('dovrebbe impostare visuForm a false', () => {
state.visuForm = true state.visuForm = true
const s = applyAction(state, { type: 'resetta' }) const s = applyAction(state, { type: 'resetta' })