okami.mom/strata

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

Niko1221apps/host: the owner's UI and the Node App Host0b3299a01

main
1.2 KiB15 linesraw
1import test from 'node:test';
2import assert from 'node:assert/strict';
3import {build} from 'esbuild';
4const compiled=await build({entryPoints:['src/lib/native-settings-response.ts'],bundle:true,write:false,platform:'node',format:'esm'});
5const {nativeSettingsResponse,nativeSettingsValues}=await import(`data:text/javascript;base64,${Buffer.from(compiled.outputFiles[0].text).toString('base64')}`);
6test('settings distinguish a host error body from a valid configuration',()=>{
7 assert.throws(()=>nativeSettingsResponse({error:'This model is not installed. Download and prepare it first.'}),/not installed/);
8 for(const value of [null,[],{}, {values:null},{values:[]},{values:{},mcp:[]}])assert.throws(()=>nativeSettingsResponse(value));
9 assert.deepEqual(nativeSettingsResponse({values:{sampling:{temperature:0.7}}}),{values:{sampling:{temperature:0.7}},mcp:{}});
10 assert.deepEqual(nativeSettingsResponse({values:{},mcp:{files:{command:'node'}}}).mcp,{files:{command:'node'}});
11});
12test('switching from raw JSON rejects scalar or array configurations before rendering fields',()=>{
13 for(const value of [null,[],true,5,'text'])assert.throws(()=>nativeSettingsValues(value));
14 assert.deepEqual(nativeSettingsValues({}),{});
15});