import { describe, expect, it } from 'vitest' import { detectLanguage } from './language.mjs' describe('detectLanguage', () => { it('recognizes English and Spanish samples', () => { expect( detectLanguage( 'This is an English paragraph about writing, links, and the web. It has enough words to detect.', ), ).toBe('eng') expect( detectLanguage( 'Este es un párrafo en español sobre escribir, enlazar y la web. Tiene suficientes palabras para detectarlo.', ), ).toBe('spa') }) it('leaves short or empty samples undecided', () => { expect(detectLanguage('')).toBeUndefined() expect(detectLanguage('A short note.')).toBeUndefined() expect(detectLanguage(undefined)).toBeUndefined() }) })