34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
formatSize,
|
|
formatAdminDate,
|
|
SIZE_KB,
|
|
SIZE_MB,
|
|
SIZE_GB,
|
|
} from '../../web/src/displayFormat.js';
|
|
|
|
test('shared display uses familiar 1024-based KB/MB/GB with comma grouping and readable whole-GB quotas', () => {
|
|
for (const [bytes, expected] of [
|
|
[0, '0KB'],
|
|
[10, '1KB 미만'],
|
|
[SIZE_KB, '1KB'],
|
|
[938 * SIZE_KB, '938KB'],
|
|
[1023 * SIZE_KB, '1,023KB'],
|
|
[SIZE_MB, '1.0MB'],
|
|
[1.1 * SIZE_MB, '1.1MB'],
|
|
[SIZE_GB, '1.0GB'],
|
|
[1.7 * SIZE_GB, '1.7GB'],
|
|
[20 * SIZE_GB, '20.0GB'],
|
|
[7687 * SIZE_GB, '7,687.0GB'],
|
|
[1234567 * SIZE_GB, '1,234,567.0GB'],
|
|
])
|
|
assert.equal(formatSize(bytes), expected);
|
|
});
|
|
|
|
test('admin dates include year and unambiguous Korea 24-hour time independent of host timezone', () => {
|
|
assert.equal(formatAdminDate(Date.parse('2026-10-22T02:02:00Z')), '2026년 10월 22일 11:02');
|
|
assert.equal(formatAdminDate(Date.parse('2026-10-21T15:02:00Z')), '2026년 10월 22일 00:02');
|
|
assert.equal(formatAdminDate(null), '확인 불가');
|
|
});
|