fix(scripts): xml-parser.test.mjs 用绝对路径修 fixture ENOENT (Task 2 fix round 1)
This commit is contained in:
@@ -2,8 +2,12 @@ import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readLayerXml } from '../../scripts/legacy-layer-to-cocos-prefab.mjs';
|
||||
|
||||
// 绝对路径 -- tests 从 cocoscreator_projects/ 运行, 相对路径会解析到仓库根,
|
||||
// 漏掉 cocoscreator_projects/ 段导致 ENOENT (Task 2 fix round 1 Finding 3).
|
||||
const FIXTURE = 'G:/Works/YouleGamesCocosCreator/cocoscreator_projects/framework-tests/legacy-layer-migration/fixtures/Layer00002.xml';
|
||||
|
||||
test('readLayerXml 解码 UTF-8 并提取 Layer00002 字段', () => {
|
||||
const layer = readLayerXml('framework-tests/legacy-layer-migration/fixtures/Layer00002.xml');
|
||||
const layer = readLayerXml(FIXTURE);
|
||||
|
||||
assert.equal(layer.layerId, '2');
|
||||
assert.equal(layer.layerName, 'Login_Layer');
|
||||
@@ -11,7 +15,7 @@ test('readLayerXml 解码 UTF-8 并提取 Layer00002 字段', () => {
|
||||
});
|
||||
|
||||
test('Spirit 字段完整提取(含中文名)', () => {
|
||||
const layer = readLayerXml('framework-tests/legacy-layer-migration/fixtures/Layer00002.xml');
|
||||
const layer = readLayerXml(FIXTURE);
|
||||
const spirit405 = layer.spirits.find(s => s.id === '405');
|
||||
assert.ok(spirit405, 'Spirit id=405 应存在');
|
||||
assert.equal(spirit405.type, '0'); // Sprite
|
||||
@@ -30,7 +34,7 @@ test('Spirit 字段完整提取(含中文名)', () => {
|
||||
});
|
||||
|
||||
test('BelongGroupID 提取(group=0 节点也存在)', () => {
|
||||
const layer = readLayerXml('framework-tests/legacy-layer-migration/fixtures/Layer00002.xml');
|
||||
const layer = readLayerXml(FIXTURE);
|
||||
for (const s of layer.spirits) {
|
||||
assert.ok(s.group !== undefined, `Spirit ${s.id} (${s.name}) 应有 group 字段`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user