From fdd1d0c9909163e286a186afff955a67b3036444 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Fri, 3 Jul 2026 11:59:17 +0200 Subject: [PATCH] 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. --- tests/unit/gameState.test.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/unit/gameState.test.js b/tests/unit/gameState.test.js index fdbe7c8..e21c22e 100644 --- a/tests/unit/gameState.test.js +++ b/tests/unit/gameState.test.js @@ -365,6 +365,13 @@ describe('Game Logic (gameState.js)', () => { 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', () => { state.modalitaPartita = '2/3' setSetVinti(state, 1, 0) @@ -508,6 +515,12 @@ describe('Game Logic (gameState.js)', () => { 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', () => { for (const team of [undefined, null, 'arbitro', '']) { const s = applyAction(state, { type: 'startTimeout', team, video: 'spot.mp4', startedAt: 1000 }) @@ -644,6 +657,12 @@ describe('Game Logic (gameState.js)', () => { // CAMBI GIOCATORI (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', () => { state.sp.form.home = ["1", "2", "3", "4", "5", "6"] const s = applyAction(state, { @@ -941,6 +960,12 @@ describe('Game Logic (gameState.js)', () => { 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', () => { state.visuForm = true const s = applyAction(state, { type: 'resetta' })