Contrat IPC typé, stockage JSON atomique, journal fichier et validation des entrées
Some checks are pending
CI / windows (push) Waiting to run

This commit is contained in:
yasder5 2026-09-28 11:40:31 +02:00
parent afb305b3e8
commit 835f8cbbbb
11 changed files with 487 additions and 15 deletions

16
tests/validate.test.ts Normal file
View file

@ -0,0 +1,16 @@
import { describe, expect, it } from 'vitest'
import { gamePatch, InvalidInput, settingsPatch } from '../src/main/validate'
describe('validation IPC', () => {
it('ignore les champs inconnus', () => {
expect(settingsPatch({ volume: 0.5, evil: 1 })).toEqual({ volume: 0.5 })
})
it('refuse les mauvais types', () => {
expect(() => settingsPatch({ volume: 3 })).toThrow(InvalidInput)
expect(() => settingsPatch({ language: 'de' })).toThrow(InvalidInput)
expect(() => gamePatch({ name: 'x'.repeat(500) })).toThrow(InvalidInput)
})
it('remplace un nom vide', () => {
expect(gamePatch({ name: ' ' }).name).toBe('Sans nom')
})
})