Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { estimateBodyFromFile } from './index.ts'
4
5describe('estimateBodyFromFile', () => {
6 it('treats a bare usage object as usage (SKILL.md usage.json)', () => {
7 expect(
8 estimateBodyFromFile({ input_tokens: 1200, output_tokens: 400 }),
9 ).toEqual({
10 usage: { input_tokens: 1200, output_tokens: 400 },
11 })
12 })
13
14 it('forwards a { request, usage } wrapper', () => {
15 expect(
16 estimateBodyFromFile({
17 request: { duration: 5 },
18 usage: { input_tokens: 1 },
19 }),
20 ).toEqual({
21 request: { duration: 5 },
22 usage: { input_tokens: 1 },
23 })
24 })
25
26 it('rejects non-objects and non-object request/usage slots', () => {
27 expect(estimateBodyFromFile(null)).toBeNull()
28 expect(estimateBodyFromFile([])).toBeNull()
29 expect(estimateBodyFromFile({ request: [] })).toBeNull()
30 expect(estimateBodyFromFile({ usage: 'nope' })).toBeNull()
31 })
32})