Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { compileReactorRate } from './reactor-pricing.ts'
4
5const SOURCE = {
6 url: 'https://api.reactor.inc/pricing',
7 hash: 'abc',
8 extractedAt: '2026-10-03T00:00:00.000Z',
9}
10
11describe('reactor pricing', () => {
12 it('compiles a published USD per second and ignores credits', () => {
13 const card = compileReactorRate(
14 {
15 amount_per_sec: 17,
16 amount_per_sec_usd: '0.0017',
17 currency_code: 'USD',
18 unit: 'credits',
19 denomination: 'second',
20 },
21 SOURCE,
22 )
23 expect(card?.price).toEqual({
24 '*': [{ var: 'video_seconds' }, 0.0017],
25 })
26 expect(card?.inputs.video_seconds).toMatchObject({ bound: 'usage' })
27 })
28
29 it('stays null when only credits are published', () => {
30 expect(
31 compileReactorRate(
32 { amount_per_sec: 17, unit: 'credits', denomination: 'second' },
33 SOURCE,
34 ),
35 ).toBeNull()
36 expect(
37 compileReactorRate(
38 {
39 amount_per_sec: 350,
40 amount_per_sec_usd: '0.0350',
41 currency_code: 'CREDITS',
42 },
43 SOURCE,
44 ),
45 ).toBeNull()
46 })
47})