Files
EJClaw/src/claude-usage.test.ts
Eyejoker 0b86f937f4 fix: read tokens from .env file, clean up debug logs
- token-rotation reads from readEnvFile() (systemd doesn't load .env)
- fetchAllClaudeUsage polling log demoted to debug level
- Remove verbose dashboard send/create logs
2026-03-23 22:41:07 +09:00

32 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import type { ClaudeUsageData } from './claude-usage.js';
describe('ClaudeUsageData', () => {
it('represents the API response structure correctly', () => {
const data: ClaudeUsageData = {
five_hour: { utilization: 45.2, resets_at: '2026-03-23T17:00:00Z' },
seven_day: { utilization: 72.1, resets_at: '2026-03-29T00:00:00Z' },
seven_day_sonnet: {
utilization: 60.0,
resets_at: '2026-03-29T00:00:00Z',
},
seven_day_opus: { utilization: 80.0, resets_at: '2026-03-29T00:00:00Z' },
};
expect(data.five_hour?.utilization).toBe(45.2);
expect(data.seven_day?.utilization).toBe(72.1);
expect(data.seven_day_sonnet?.utilization).toBe(60.0);
expect(data.seven_day_opus?.utilization).toBe(80.0);
});
it('allows partial data (only five_hour)', () => {
const data: ClaudeUsageData = {
five_hour: { utilization: 10, resets_at: '2026-03-23T17:00:00Z' },
};
expect(data.five_hour?.utilization).toBe(10);
expect(data.seven_day).toBeUndefined();
});
});