/** @jest-environment node */ import {createDetailLayerObject} from '@/lib/detail-generator/layer-rendering' test('generated box text has the same bounded multiline width in preview and export; old templates retain calibration',async()=>{ class Textbox{width:number;constructor(public text:string,public options:any){Object.assign(this,options);this.width=options.width}set(value:any){Object.assign(this,value)}} const fabric={Textbox} as any,measure={font:'',measureText:()=>({width:30})} as any const base={id:'body',name:'正文',kind:'text' as const,sourceId:0,x:88,y:210,width:1264,height:100,font:'NotoSansSC-Regular',fontSize:30,color:'#55514b',text:'棕色桌面'.repeat(25),originalText:'棕色桌面'.repeat(25),originalLines:1,locked:false} const box=await createDetailLayerObject({...base,textLayout:'box'},fabric,async()=>'',measure) const template=await createDetailLayerObject(base,fabric,async()=>'',measure) expect(box.width).toBe(1264);expect(template.width).toBeGreaterThan(1264) })