fix(quota): accept epoch reset timestamps (#1241)

* fix(quota): accept epoch reset timestamps

* fix(quota): format epoch reset windows

---------

Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
Isaac Sanchez-Hawkins
2026-05-13 10:30:42 +03:00
committed by GitHub
co-authored by Isaac Sanchez
parent f059bc8dd6
commit c005c59186
2 changed files with 19 additions and 3 deletions
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { calculateResetAfterSeconds, formatResetTime } from './formatters.js';
import { calculateResetAfterSeconds, formatResetTime, toUsageWindow } from './formatters.js';
describe('formatResetTime', () => {
it('returns null for invalid timestamps', () => {
@@ -12,6 +12,10 @@ describe('formatResetTime', () => {
});
describe('calculateResetAfterSeconds', () => {
it('accepts an epoch reset timestamp', () => {
expect(calculateResetAfterSeconds(0)).toBe(0);
});
it('returns null for invalid timestamps', () => {
expect(calculateResetAfterSeconds('not-a-date')).toBeNull();
expect(calculateResetAfterSeconds(NaN)).toBeNull();
@@ -19,3 +23,13 @@ describe('calculateResetAfterSeconds', () => {
expect(calculateResetAfterSeconds(-Infinity)).toBeNull();
});
});
describe('toUsageWindow', () => {
it('formats epoch reset timestamps', () => {
const usageWindow = toUsageWindow({ resetAt: 0 });
expect(usageWindow.resetAfterSeconds).toBe(0);
expect(usageWindow.resetAtFormatted).toBe(formatResetTime(0));
expect(usageWindow.resetAfterFormatted).toBe(formatResetTime(0));
});
});