1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { formatUploadSpeed, formatContainerCost } from "./formatters";
7 describe('formatUploadSpeed', () => {
8 it('should show speed less than 1MB/s', () => {
13 const result = formatUploadSpeed(0, speed, 0, 1);
16 expect(result).toBe('0.90 MB/s');
19 it('should show 5MB/s', () => {
24 const result = formatUploadSpeed(0, speed, 0, 1);
27 expect(result).toBe('5.23 MB/s');
31 describe('formatContainerCost', () => {
32 it('should correctly round to tenth of a cent', () => {
33 expect(formatContainerCost(0.0)).toBe('$0');
34 expect(formatContainerCost(0.125)).toBe('$0.125');
35 expect(formatContainerCost(0.1254)).toBe('$0.125');
36 expect(formatContainerCost(0.1255)).toBe('$0.126');
39 it('should round up any smaller value to 0.001', () => {
40 expect(formatContainerCost(0.0)).toBe('$0');
41 expect(formatContainerCost(0.001)).toBe('$0.001');
42 expect(formatContainerCost(0.0001)).toBe('$0.001');
43 expect(formatContainerCost(0.00001)).toBe('$0.001');