21 lines
1.8 KiB
JavaScript
21 lines
1.8 KiB
JavaScript
const fs=require('fs'), ts=require('typescript'), assert=require('node:assert/strict');
|
|
const code=ts.transpileModule(fs.readFileSync('assets/Script/coin_madness/CoinMadnessHost.ts','utf8'),{compilerOptions:{target:ts.ScriptTarget.ES2017,module:ts.ModuleKind.CommonJS,experimentalDecorators:true}}).outputText;
|
|
const loaded=[]; let options;
|
|
const entry={active:false};
|
|
const service={readForDisplay:()=>Promise.resolve({}),refresh:()=>Promise.resolve({}),settlementNotice:500,hasBadge:true,serverNow:200,info:{endsAt:100,status:'unavailable'},dismissNotice(){this.settlementNotice=0;}};
|
|
const bundle={load(path,type,cb){loaded.push(path);cb(null,{});}};
|
|
const cc={Component:class{},_decorator:{ccclass:C=>C},Prefab:class{},macro:{MAX_ZINDEX:999},
|
|
fx:{GameConfig:{GM_INFO:{canIos:true}}},find:()=>entry,
|
|
assetManager:{loadBundle(name,cb){cb(null,bundle);}},
|
|
instantiate:()=>({getComponent:()=>({initialize(data,api){assert.equal(data.state.settlementCoins,500);options=api;}})})};
|
|
const exportsHost={};new Function('require','exports','cc',code)(()=>({}),exportsHost,cc);
|
|
const host=new exportsHost.default();host.node={addChild(){},getComponent(){return null}};
|
|
host.service=service;host.entry=entry;host.refreshCoinDisplay=host.clearHelp=host.layoutEntry=host.refreshEntryBadge=()=>{};
|
|
host.close=()=>{host.panel=null;};
|
|
host.load();
|
|
assert.deepEqual(loaded,['prefab/CoinMadnessSettlement'],'never load or instantiate the main activity for a notice');
|
|
host.updateEntry();assert.equal(entry.active,true);
|
|
options.close();assert.equal(entry.active,false,'closing notice immediately hides expired entry despite stale task badge');
|
|
service.info={endsAt:300,status:'purchasable'};host.updateEntry();assert.equal(entry.active,true,'a new active period keeps its entry');
|
|
console.log('PASS: direct settlement load, immediate expired-entry removal and active-period preservation');
|