Files
frontend-app-authoring/src/utils.test.js
Rômulo Penido b59ecafc83 feat: refined ux update a taxonomy by downloading and uploading [FC-0036] (#732)
This PR improves the import tags functionality for existing taxonomies implemented at #675.

Co-authored-by: Jillian <jill@opencraft.com>
Co-authored-by: Braden MacDonald <mail@bradenm.com>
2024-01-16 12:00:15 +05:30

37 lines
1.4 KiB
JavaScript

import { getFileSizeToClosestByte } from './utils';
describe('FilesAndUploads utils', () => {
describe('getFileSizeToClosestByte', () => {
it('should return file size with B for bytes', () => {
const expectedSize = '219.00 B';
const actualSize = getFileSizeToClosestByte(219);
expect(expectedSize).toEqual(actualSize);
});
it('should return file size with KB for kilobytes', () => {
const expectedSize = '21.90 KB';
const actualSize = getFileSizeToClosestByte(21900);
expect(expectedSize).toEqual(actualSize);
});
it('should return file size with MB for megabytes', () => {
const expectedSize = '2.19 MB';
const actualSize = getFileSizeToClosestByte(2190000);
expect(expectedSize).toEqual(actualSize);
});
it('should return file size with GB for gigabytes', () => {
const expectedSize = '2.03 GB';
const actualSize = getFileSizeToClosestByte(2034190000);
expect(expectedSize).toEqual(actualSize);
});
it('should return file size with TB for terabytes', () => {
const expectedSize = '1.99 TB';
const actualSize = getFileSizeToClosestByte(1988034190000);
expect(expectedSize).toEqual(actualSize);
});
it('should return file size with TB for larger numbers', () => {
const expectedSize = '1234.56 TB';
const actualSize = getFileSizeToClosestByte(1234560000000000);
expect(expectedSize).toEqual(actualSize);
});
});
});