Complete room UI and protocol integration, move game definitions and resources behind bundle entries, publish authoritative version XML, and document single-game builds. Include all current resource changes and experiment artifacts.
36 lines
2.4 KiB
TypeScript
36 lines
2.4 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {PlatformSettings} from '../../YouleNexus/assets/framework/presentation/platform-settings.ts';
|
|
|
|
function storage(){const values=new Map<string,string>();return {values,getItem:(k:string)=>values.get(k)??null,setItem:(k:string,v:string)=>{values.set(k,v);}};}
|
|
test('browser switches default on, persist independently, and restore after reopening',()=>{
|
|
const store=storage();const settings=new PlatformSettings(store,568,3,{kind:'browser'});
|
|
assert.equal(settings.read('shake'),true);assert.equal(settings.read('voice'),true);
|
|
assert.equal(settings.toggle('shake'),false);assert.equal(settings.toggle('voice'),false);
|
|
const reopened=new PlatformSettings(store,568,3,{kind:'browser'});
|
|
assert.equal(reopened.read('shake'),false);assert.equal(reopened.read('voice'),false);
|
|
assert.equal(reopened.toggle('shake'),true);
|
|
assert.equal(store.getItem('tsgame_shake_5683'),'1');assert.equal(store.getItem('tsgame_voice_5683'),'0');
|
|
assert.equal(new PlatformSettings(store,568,4,{kind:'browser'}).read('voice'),true);
|
|
});
|
|
test('lobby toggles preserve native voice and shake sound commands without starting a game shake action',()=>{
|
|
const store=storage();const calls:unknown[]=[];
|
|
const settings=new PlatformSettings(store,568,3,{kind:'bridge',call:(name,data)=>calls.push([name,data])});
|
|
settings.toggle('voice');settings.toggle('voice');settings.toggle('shake');
|
|
store.setItem('tsgame_sound_5683','0');settings.toggle('shake');settings.toggle('sound');
|
|
assert.deepEqual(calls,[['voicePlaying',0],['voicePlaying',1],['stopshake',''],['SwitchShake',0],['SwitchShake',1]]);
|
|
});
|
|
test('invalid saved preferences are exposed rather than silently replaced',()=>{
|
|
const store=storage();store.setItem('tsgame_voice_5683','bad');
|
|
const settings=new PlatformSettings(store,568,3,{kind:'browser'});
|
|
assert.throws(()=>settings.toggle('voice'),/tsgame_voice_5683/);
|
|
assert.equal(store.getItem('tsgame_voice_5683'),'bad');
|
|
});
|
|
test('entering the lobby restores a cached muted voice state to native',()=>{
|
|
const store=storage();store.setItem('tsgame_voice_5683','0');const calls:unknown[]=[];
|
|
const settings=new PlatformSettings(store,568,3,{kind:'bridge',call:(name,data)=>calls.push([name,data])});
|
|
settings.synchronizeVoice();
|
|
assert.deepEqual(calls,[['voicePlaying',0]]);
|
|
assert.equal(settings.read('voice'),false);
|
|
});
|