client-total-bytes.test.tsx 775 B

1234567891011121314151617181920
  1. import { describe, it, expect } from 'vitest';
  2. import { resolveTotalBytes, gbToBytes } from '@/pages/clients/ClientFormModal';
  3. describe('resolveTotalBytes', () => {
  4. it('preserves the original byte total on a no-op save of a non-GB-aligned quota', () => {
  5. const original = 11_505_016_832;
  6. const displayedGB = Math.round((original / 1024 ** 3) * 100) / 100;
  7. expect(resolveTotalBytes(original, displayedGB)).toBe(original);
  8. });
  9. it('re-derives bytes from GB when the user changed the quota', () => {
  10. const original = 11_505_016_832;
  11. expect(resolveTotalBytes(original, 20)).toBe(gbToBytes(20));
  12. });
  13. it('uses the GB value directly when there is no original (add mode)', () => {
  14. expect(resolveTotalBytes(null, 5)).toBe(gbToBytes(5));
  15. });
  16. });