import { test } from 'node:test'; import assert from 'node:assert/strict'; import { resolveSpriteFrameUuid, selectAtlasForLayerName } from '../../scripts/legacy-layer-to-cocos-prefab.mjs'; // 数据源权威: gameabc_Image.json id=20 -> bmp="00020.png" 位于 atlas-login/, // 该 .meta 的 subMetas.f9941.uuid 为 e36acab8-e623-4bfb-af05-3c6fd2fddfb4@f9941 // (SpriteFrame 真 UUID, 含 sub-asset 后缀). test('resolveSpriteFrameUuid("20") 返回 atlas-login/00020.png 的 SpriteFrame 真 UUID', () => { const uuid = resolveSpriteFrameUuid('20'); assert.equal(uuid, 'e36acab8-e623-4bfb-af05-3c6fd2fddfb4@f9941'); assert.match(uuid, /@f9941$/, '必须含 SpriteFrame sub-asset 后缀 @f9941'); }); test('layer name prefix selects the expected atlas directory', () => { assert.equal(selectAtlasForLayerName('Login_Layer'), 'atlas-login'); assert.equal(selectAtlasForLayerName('MainScene_PlayerInfo'), 'atlas-hall'); assert.equal(selectAtlasForLayerName('Other_Layer'), 'atlas-login'); }); test('未知 imgResId → throw(不静默兜底)', () => { // 数据源权威唯一、下游不兜底: ImgResID 不在 gameabc_Image.json 时必须显式报错. assert.throws( () => resolveSpriteFrameUuid('99999999'), /ImgResID .* not in gameabc_Image\.json/ ); });