import { describe, expect, it } from 'vitest'; import { parseSearchLimit } from '../src/searchLimit'; describe('parseSearchLimit', () => { it.each([ ['25', 25], ['1', 1], [' 40 ', 40], ['1000', 1000], ['007', 7], ])('lit %j comme une limite de %i résultats', (raw, expected) => { expect(parseSearchLimit(raw)).toBe(expected); }); it.each([ ['un champ vide', ''], ['des espaces', ' '], ['zéro', '0'], ['un nombre négatif', '-5'], ['un nombre décimal', '2.5'], ['du texte', 'beaucoup'], ['un nombre suivi de texte', '25 vidéos'], ['une notation exponentielle', '1e3'], ])('ne voit aucune limite dans %s', (_label, raw) => { expect(parseSearchLimit(raw)).toBeNull(); }); });