File size: 942 Bytes
0624276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)
  })
})