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:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
f059bc8dd6
commit
c005c59186
@@ -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));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user