13 lines
603 B
TypeScript
13 lines
603 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { GiB, quotaBytes } from './quota';
|
|
describe('quota validation', () => {
|
|
it('converts presets and fractional GiB to integer bytes', () => {
|
|
for (const n of [5,10,20,50]) expect(quotaBytes(String(n))).toBe(n * GiB);
|
|
expect(quotaBytes('0.1')).toBe(Math.round(GiB / 10));
|
|
expect(quotaBytes('10')).toBe(quotaBytes('10.0'));
|
|
});
|
|
it('rejects empty, nonfinite, negative and unsafe values', () => {
|
|
for (const value of ['', ' ', 'invalid', '0', '-5', '0.09', 'Infinity', 'NaN', '1e30']) expect(quotaBytes(value)).toBeNull();
|
|
});
|
|
});
|