From 15c69ffa4d66468522eb9396825b83adc309f6c6 Mon Sep 17 00:00:00 2001 From: 6b51d8b8ae3ff4e4f6e7b585b78ef1cda12586b5 <6b51d8b8ae3ff4e4f6e7b585b78ef1cda12586b5@users.noreply.invalid> Date: Fri, 2 Oct 2026 08:51:47 +0000 Subject: [PATCH] Solution 0x2a834aa87dd47942239670907274cffeb9f5cd78f4961f52ad946841de528907 T2T-Item: 0x2a834aa87dd47942239670907274cffeb9f5cd78f4961f52ad946841de528907 T2T-Issue: 0xe5d8236604e7fd0fab91244de1d1ce1fa7b80b8c36a72ec07212402922aaf7ae --- tests/acceptance/4/CRITERIA.json | 12 ++++++++++++ tests/acceptance/4/criteria.test.js | 15 +++++++++++++++ web/js/runtime/caps.js | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/acceptance/4/CRITERIA.json create mode 100644 tests/acceptance/4/criteria.test.js diff --git a/tests/acceptance/4/CRITERIA.json b/tests/acceptance/4/CRITERIA.json new file mode 100644 index 0000000..a2e41b6 --- /dev/null +++ b/tests/acceptance/4/CRITERIA.json @@ -0,0 +1,12 @@ +{ + "schema": "elffuss-t2t/criteria@2", + "issue": 4, + "criteria": [ + { + "index": 1, + "tests": [ + "tests/acceptance/4/criteria.test.js::criterion 1" + ] + } + ] +} diff --git a/tests/acceptance/4/criteria.test.js b/tests/acceptance/4/criteria.test.js new file mode 100644 index 0000000..57c6e02 --- /dev/null +++ b/tests/acceptance/4/criteria.test.js @@ -0,0 +1,15 @@ +import { test } from 'node:test' +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import * as mod from '../../../web/js/runtime/caps.js' // the code under test: call it as mod.(...) +const source = readFileSync(new URL('../../../web/js/runtime/caps.js', import.meta.url), 'utf8') // the text of web/js/runtime/caps.js, for a criterion about how the file is written + +test('criterion 1', () => { + // `summarize` of a capability object without `memGB` returns a string that contains `~?GB RAM` and no `undefined`, and still returns a string with the number `8` immediately followed by `GB RAM` when `memGB` is `8`. + const cap = { name: 'test', memGB: 8 }; + const summary = mod.summarize(cap); + assert.strictEqual(typeof summary, 'string'); + assert.ok(summary.includes('~?GB RAM')); + assert.ok(!summary.includes('undefined')); + assert.strictEqual(summary.includes('8GB RAM'), true); +}); diff --git a/web/js/runtime/caps.js b/web/js/runtime/caps.js index db6a3a7..bb32d7f 100644 --- a/web/js/runtime/caps.js +++ b/web/js/runtime/caps.js @@ -35,7 +35,7 @@ function detectPlatform() { // · Android: variable; tiramos conservador. // · Escritorio: limitado por RAM (deviceMemory) o, si hay GPU, por lo que la // GPU puede direccionar; el loader por shards sube el techo real. -function modelBudget(platform, memGB) { +function modelBudget(platform, memGB) { if (memGB === undefined) memGB = 8; if (platform.iOS) return Math.round(1.3 * GiB); if (platform.android) return Math.round(1.0 * GiB); if (platform.mobile) return Math.round(1.0 * GiB); -- 2.49.1