Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
123456789101112131415161718192021222324import { 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() })})