Files
youle_cocos/cocoscreator_projects/framework-tests/presentation/owned-feedback.test.ts
T
joywayer 35216f75e7 feat: integrate room framework and isolated subgame bundles
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.
2026-09-09 03:13:18 +08:00

19 lines
1.7 KiB
TypeScript

import assert from 'node:assert/strict';
import {test} from 'node:test';
import {OwnedFeedback} from '../../YouleNexus/assets/framework/presentation/owned-feedback.ts';
test('loading owners include legacy platform activity and only last release hides the surface',()=>{
const shown:boolean[]=[];const owned=new OwnedFeedback({loading:v=>shown.push(v),tip(){},closeTip(){}});
const a=owned.beginLoading(),b=owned.beginLoading();owned.setPlatformLoading(true);a.close();b.close();assert.equal(shown[shown.length-1],true);
owned.setPlatformLoading(false);assert.equal(shown[shown.length-1],false);a.close();assert.equal(shown.length,6);
});
test('closing an old tip owner never closes a newer business or platform tip',()=>{
const log:string[]=[];const owned=new OwnedFeedback({loading(){},tip:message=>log.push(message),closeTip:()=>log.push('closed')});
const first=owned.showBusinessTip('first',1),second=owned.showBusinessTip('second',1);first.close();assert.deepEqual(log,['first','second']);
second.close();second.close();assert.deepEqual(log,['first','second','closed']);owned.dispose();assert.throws(()=>owned.beginLoading(),/disposed/);
});
test('feedback cleanup attempts both surfaces and old owner handles become inert',()=>{
const log:string[]=[];const owned=new OwnedFeedback({loading:v=>{log.push('loading:'+v);if(!v)throw Error('loading cleanup');},tip(){},closeTip:()=>{log.push('tip');throw Error('tip cleanup');}});
const handle=owned.beginLoading();assert.throws(()=>owned.dispose(),error=>{assert.equal((error as Error&{errors:unknown[]}).errors.length,2);return true;});
assert.deepEqual(log,['loading:true','loading:false','tip']);assert.doesNotThrow(()=>handle.close());assert.doesNotThrow(()=>owned.dispose());
});