Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2import {
3 formatReasoningShape,
4 reasoningShapeName,
5 reasoningShapeTable,
6} from './reasoning-shapes'
7
8describe('reasoning shapes', () => {
9 it('names a shape after its levels and values', () => {
10 expect(
11 reasoningShapeName({
12 levels: { off: 'none', low: 'low', medium: 'medium', high: 'high' },
13 budget: false,
14 }),
15 ).toBe('EFFORT_NONE_LOW_TO_HIGH')
16 expect(
17 reasoningShapeName({
18 levels: { off: 'false', high: 'true' },
19 budget: false,
20 }),
21 ).toBe('EFFORT_FALSE_TRUE')
22 expect(
23 reasoningShapeName({
24 levels: { low: 'low', high: 'high', max: 'max' },
25 budget: true,
26 }),
27 ).toBe('BUDGET_LOW_HIGH_MAX')
28 })
29
30 it('writes the levels from least to most thinking', () => {
31 expect(
32 formatReasoningShape({
33 levels: { high: 'high', off: 'none' },
34 budget: false,
35 }),
36 ).toBe(`{ levels: { off: 'none', high: 'high' }, budget: false }`)
37 })
38
39 it('writes one constant per distinct shape', () => {
40 const shape = { levels: { high: 'high' }, budget: false }
41 const { names, code } = reasoningShapeTable([shape, { ...shape }])
42 expect([...names.values()]).toEqual(['EFFORT_HIGH'])
43 expect(code).toBe(
44 `const EFFORT_HIGH = { levels: { high: 'high' }, budget: false } as const`,
45 )
46 })
47})