test(timeout): copri toggleTimeout e listSpotVideos
- gameState: stato iniziale `timeout: false` e ciclo toggleTimeout. - nuovo spotUtils.test.js: cartella assente/vuota, filtro .mp4 ordinato, estensione case-insensitive.
This commit is contained in:
@@ -79,6 +79,10 @@ describe('Game Logic (gameState.js)', () => {
|
|||||||
expect(state.visuForm).toBe(false)
|
expect(state.visuForm).toBe(false)
|
||||||
expect(state.visuStriscia).toBe(true)
|
expect(state.visuStriscia).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('dovrebbe avere timeout false', () => {
|
||||||
|
expect(state.timeout).toBe(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// =============================================
|
// =============================================
|
||||||
@@ -479,6 +483,14 @@ describe('Game Logic (gameState.js)', () => {
|
|||||||
const s = applyAction(state, { type: 'toggleOrder' })
|
const s = applyAction(state, { type: 'toggleOrder' })
|
||||||
expect(s.order).toBe(false)
|
expect(s.order).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('toggleTimeout: false → true → false', () => {
|
||||||
|
expect(state.timeout).toBe(false)
|
||||||
|
const s1 = applyAction(state, { type: 'toggleTimeout' })
|
||||||
|
expect(s1.timeout).toBe(true)
|
||||||
|
const s2 = applyAction(s1, { type: 'toggleTimeout' })
|
||||||
|
expect(s2.timeout).toBe(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||||
|
import { mkdtempSync, writeFileSync, rmSync } from 'fs'
|
||||||
|
import { tmpdir } from 'os'
|
||||||
|
import { join } from 'path'
|
||||||
|
import { listSpotVideos } from '../../src/spot-utils.js'
|
||||||
|
|
||||||
|
describe('listSpotVideos (spot-utils.js)', () => {
|
||||||
|
let dir
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
dir = mkdtempSync(join(tmpdir(), 'spot-test-'))
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
rmSync(dir, { recursive: true, force: true })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('ritorna [] se la cartella non esiste', () => {
|
||||||
|
expect(listSpotVideos(join(dir, 'inesistente'))).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('ritorna [] se la cartella è vuota', () => {
|
||||||
|
expect(listSpotVideos(dir)).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('elenca solo i file .mp4, ordinati alfabeticamente', () => {
|
||||||
|
writeFileSync(join(dir, 'b.mp4'), '')
|
||||||
|
writeFileSync(join(dir, 'a.mp4'), '')
|
||||||
|
writeFileSync(join(dir, 'note.txt'), '')
|
||||||
|
writeFileSync(join(dir, 'foto.png'), '')
|
||||||
|
expect(listSpotVideos(dir)).toEqual(['a.mp4', 'b.mp4'])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('riconosce l\'estensione .mp4 senza distinzione di maiuscole', () => {
|
||||||
|
writeFileSync(join(dir, 'SPOT.MP4'), '')
|
||||||
|
expect(listSpotVideos(dir)).toEqual(['SPOT.MP4'])
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user