同步小程序与管理端更新,完善抽烟记录和解绑冷静期

This commit is contained in:
2026-10-09 22:15:51 +08:00
parent a68a4ef411
commit b10fc3c4ac
149 changed files with 3794 additions and 589 deletions
+16
View File
@@ -0,0 +1,16 @@
const test=require('node:test');
const assert=require('node:assert/strict');
const path=require('node:path');
const createLoader=require('./load-module.cjs');
test('pet page guides unbound users to binding and loads adoption after binding',async()=>{
let definition,unbound=true,calls=0,url;const app={globalData:{}};
const load=createLoader({Page:p=>definition=p,console,Date,getApp:()=>app,wx:{switchTab:p=>url=p.url}}, {
'../../utils/page-cache':{withDataCache:p=>p},
'../../utils/request':{api:{coupleInfo:async()=>({not_bound:unbound}),petInfo:async()=>{calls++;return {has_pet:false};}}}
});
load(path.join(__dirname,'../pages/pet/pet.js'));
const page={...definition,data:{...definition.data},setData:p=>Object.assign(page.data,p)};
await page.loadPetInfo();assert.equal(calls,0);assert.equal(page.data.needsBinding,true);assert.equal(page.data.loading,false);assert.equal(page.data.loadError,false);
page.bindPartner();assert.equal(app.globalData.openProfileBind,true);assert.equal(url,'/pages/profile/profile');
unbound=false;await page.loadPetInfo();assert.equal(calls,1);assert.equal(page.data.needsBinding,false);assert.equal(page.data.hasPet,false);
});