This takes part of the work being done in #96 that was reverted but still useful. Note Tailwind and Fresh weren't upgraded because there's no security vulnerability in either, and I have found the new versions to be worse in performance. Thos will likely stay at those fixed versions going forward.
38 lines
680 B
TypeScript
38 lines
680 B
TypeScript
import { assertEquals } from '@std/assert';
|
|
|
|
import { humanFileSize } from './files.ts';
|
|
|
|
Deno.test('that humanFileSize works', () => {
|
|
const tests: { input: number; expected: string }[] = [
|
|
{
|
|
input: 1000,
|
|
expected: '1000 B',
|
|
},
|
|
{
|
|
input: 1024,
|
|
expected: '1.00 KB',
|
|
},
|
|
{
|
|
input: 10000,
|
|
expected: '9.77 KB',
|
|
},
|
|
{
|
|
input: 1,
|
|
expected: '1 B',
|
|
},
|
|
{
|
|
input: 1048576,
|
|
expected: '1.00 MB',
|
|
},
|
|
{
|
|
input: 1073741824,
|
|
expected: '1.00 GB',
|
|
},
|
|
];
|
|
|
|
for (const test of tests) {
|
|
const output = humanFileSize(test.input);
|
|
assertEquals(output, test.expected);
|
|
}
|
|
});
|