Files
ange 2edbe71367 v0.6.0 : ligne d'état unifiée, délégation imposée et retrait des types
- fusion du bandeau et de l'ancienne ligne d'état en une seule ligne d'état
- refus de la lecture des longs fichiers et enregistrement des longues sorties shell
- ajout du réglage « imposer », actif par défaut, sans blocage si MIAM ne répond pas
- suppression du fichier types/index.d.ts
2026-10-31 10:39:33 +01:00

51 lines
1.9 KiB
TypeScript

import { expect, test } from 'claude-code/testing'
import { lectureTropLongue, nomSortie, PLAGE_MAX, SEUIL, sortieTropLongue } from './contrainte'
test('frontière de taille', () => {
expect(lectureTropLongue({ file_path: 'a.txt' }, 19999)).toBe(false)
expect(lectureTropLongue({ file_path: 'a.txt' }, 20000)).toBe(true)
})
test('extensions image et PDF', () => {
expect(lectureTropLongue({ file_path: 'A.PNG' }, 20000)).toBe(false)
expect(lectureTropLongue({ file_path: 'x.jpg' }, 20000)).toBe(false)
expect(lectureTropLongue({ file_path: 'x.JPEG' }, 20000)).toBe(false)
expect(lectureTropLongue({ file_path: 'x.gif' }, 20000)).toBe(false)
expect(lectureTropLongue({ file_path: 'x.webp' }, 20000)).toBe(false)
expect(lectureTropLongue({ file_path: 'x.pdf' }, 20000)).toBe(false)
expect(lectureTropLongue({ file_path: 'x.md' }, 20000)).toBe(true)
})
test('chemin non chaîne', () => {
expect(lectureTropLongue({ file_path: 42 }, 20000)).toBe(false)
expect(lectureTropLongue({}, 20000)).toBe(false)
})
test('limites de plage', () => {
expect(lectureTropLongue({ file_path: 'a.txt', limit: 400 }, 20000)).toBe(false)
expect(lectureTropLongue({ file_path: 'a.txt', limit: 401 }, 20000)).toBe(true)
expect(lectureTropLongue({ file_path: 'a.txt', limit: 0 }, 20000)).toBe(true)
expect(lectureTropLongue({ file_path: 'a.txt', limit: 1 }, 20000)).toBe(false)
})
test('limit texte', () => {
expect(lectureTropLongue({ file_path: 'a.txt', limit: '10' }, 20000)).toBe(true)
})
test('sortie trop longue', () => {
expect(sortieTropLongue('x'.repeat(19999))).toBe(false)
expect(sortieTropLongue('x'.repeat(20000))).toBe(true)
expect(sortieTropLongue(undefined)).toBe(false)
})
test('nom de sortie', () => {
expect(nomSortie('toolu_01-AB')).toBe('sortie-toolu_01-AB.txt')
expect(nomSortie('a/b:c')).toBe('sortie-a_b_c.txt')
})
test('constantes', () => {
expect(SEUIL).toBe(20000)
expect(PLAGE_MAX).toBe(400)
})