smol-neuron-studio / web /tests /exampleText.test.ts
lorcapoul's picture
Smol Neuron Studio
0624276 verified
Raw History Blame Contribute Delete
942 Bytes
import { describe, expect, it } from 'vitest'
import { confidenceLevel, exampleSegments } from '../app/utils/exampleText'
describe('exampleSegments', () => {
const tokens = ['The', ' capital', ' of', ' France', ' is', ' Paris', '.', '\n', 'It']
it('parte alrededor del token marcado', () => {
const s = exampleSegments(tokens, 3, 2)
expect(s).toEqual({ before: ' capital of ', token: 'France', after: ' is Paris', clippedLeft: true, clippedRight: true })
})
it('sin recorte en los bordes y saltos de línea visibles', () => {
const s = exampleSegments(tokens, 6, 20)
expect(s.clippedLeft).toBe(false)
expect(s.clippedRight).toBe(false)
expect(s.after).toBe(' ↵ It')
})
})
describe('confidenceLevel', () => {
it.each([
[0.95, 'high'],
[0.8, 'high'],
[0.6, 'medium'],
[0.3, 'low'],
[0.1, 'none'],
])('%s → %s', (c, level) => {
expect(confidenceLevel(c)).toBe(level)
})
})