Makelore 2.0 initial clean snapshot
This commit is contained in:
30
tests/unit/works-square-token-usage.test.ts
Normal file
30
tests/unit/works-square-token-usage.test.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { isWorksTokenUsageExhausted } from '@/lib/works-square-token-usage';
|
||||
|
||||
describe('isWorksTokenUsageExhausted', () => {
|
||||
it('returns true when either rolling window is exhausted', () => {
|
||||
expect(isWorksTokenUsageExhausted({
|
||||
five_hour_remaining_percent: 50,
|
||||
weekly_remaining_percent: 0,
|
||||
})).toBe(true);
|
||||
expect(isWorksTokenUsageExhausted({
|
||||
five_hour_remaining_percent: 0,
|
||||
weekly_remaining_percent: 40,
|
||||
})).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false while both rolling windows have remaining allowance', () => {
|
||||
expect(isWorksTokenUsageExhausted({
|
||||
five_hour_remaining_percent: 50,
|
||||
weekly_remaining_percent: 40,
|
||||
})).toBe(false);
|
||||
});
|
||||
|
||||
it('does not treat missing or non-finite usage as confirmed exhaustion', () => {
|
||||
expect(isWorksTokenUsageExhausted(undefined)).toBe(false);
|
||||
expect(isWorksTokenUsageExhausted({
|
||||
five_hour_remaining_percent: null,
|
||||
weekly_remaining_percent: Number.NaN,
|
||||
})).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user