okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-0243-gui into f-0243-rel (Chat.tsx and DropZone.tsx: the guifix clipboard helpers kept at the conflicts, copyAndTell stays for Markdown and Serving)061a28583

main
1.1 KiB17 linesraw
1/** The first-run card and the update check show decimal megabytes, the same figure as the Terminal and the release page. */
2import test from 'node:test';
3import assert from 'node:assert/strict';
4import { build } from 'esbuild';
5import { fileURLToPath } from 'node:url';
6
7const out = await build({ entryPoints: [fileURLToPath(new URL('../src/lib/format.ts', import.meta.url))], bundle: true, format: 'esm', platform: 'node', write: false, logLevel: 'silent' });
8const { megabytes } = await import(`data:text/javascript;base64,${Buffer.from(out.outputFiles[0].text).toString('base64')}`);
9
10test('engine sizes are decimal megabytes: 606,513,890 bytes is 607 MB, not 578', () => {
11  assert.equal(megabytes(606513890), 607);
12  assert.equal(megabytes(581299508), 581);
13  assert.equal(megabytes(1), 1);
14  assert.equal(megabytes(0), 1);
15  // the same samples as tests/terminal/test_size_label.py: the Terminal and the app agree
16  for (const [bytes, expected] of [[606513890, 607], [581299508, 581], [1, 1], [0, 1], [999_999, 1], [1_500_000, 2], [2_499_999, 2]]) assert.equal(megabytes(bytes), expected, String(bytes));
17});