feat(striscia): registra cambi e time out per set (#18)
La striscia salva ora storico cambi formazione e time out per ogni set, con riferimento al punteggio al momento dell'evento anziché a un timestamp: startTimeout accumula in set.timeouts, confermaCambi in set.cambi. Il referto elenca entrambi ordinati per punteggio.
This commit is contained in:
@@ -97,6 +97,38 @@ describe('buildRefertoHtml (referto.js)', () => {
|
||||
expect(html).toContain('Nessun punto registrato')
|
||||
})
|
||||
|
||||
it('elenca time out e cambi del set con squadra e punteggio', () => {
|
||||
const striscia = [{
|
||||
serv: 'h', ris: 'hhhg', vinc: null,
|
||||
timeouts: [{ team: 'guest', punteggio: { home: 3, guest: 1 } }],
|
||||
cambi: [{ team: 'home', in: '10', out: '3', punteggio: { home: 2, guest: 0 } }],
|
||||
}]
|
||||
const html = buildRefertoHtml(statoConSet(striscia), NOW)
|
||||
expect(html).toContain('Cambi e time out')
|
||||
expect(html).toContain('Time out <strong>Rivali</strong> sul 3-1')
|
||||
expect(html).toContain('Cambio <strong>Antoniana</strong>: entra 10 per 3 sul 2-0')
|
||||
})
|
||||
|
||||
it('ordina gli eventi per punteggio crescente', () => {
|
||||
const striscia = [{
|
||||
serv: 'h', ris: 'hhhgg', vinc: null,
|
||||
timeouts: [{ team: 'home', punteggio: { home: 3, guest: 2 } }],
|
||||
cambi: [{ team: 'guest', in: '9', out: '4', punteggio: { home: 1, guest: 0 } }],
|
||||
}]
|
||||
const html = buildRefertoHtml(statoConSet(striscia), NOW)
|
||||
const idxCambio = html.indexOf('entra 9 per 4')
|
||||
const idxTimeout = html.indexOf('Time out')
|
||||
expect(idxCambio).toBeGreaterThan(-1)
|
||||
expect(idxTimeout).toBeGreaterThan(-1)
|
||||
expect(idxCambio).toBeLessThan(idxTimeout)
|
||||
})
|
||||
|
||||
it('omette la sezione eventi se il set non ne ha', () => {
|
||||
const striscia = [{ serv: 'h', ris: 'h', vinc: null }]
|
||||
const html = buildRefertoHtml(statoConSet(striscia), NOW)
|
||||
expect(html).not.toContain('Cambi e time out')
|
||||
})
|
||||
|
||||
it('header contiene nomi squadre, modalità e data iniettata', () => {
|
||||
const striscia = [{ serv: 'h', ris: '', vinc: null }]
|
||||
const state = statoConSet(striscia)
|
||||
|
||||
Reference in New Issue
Block a user