Files
Genarrative/apps/ai-game-creator-shell/tests/uiTreeUtils.test.ts
T
k88936 594063a1e0 测试:修正 AGC 测试文件的类型错误
- 按 vitest 0.34 的参数元组口径改写 mock 泛型
- 修正 noUncheckedIndexedAccess 下的下标访问
- 补齐与当前类型脱节的测试桩字段
- 按 scripts/*.mjs 的运行时契约补局部类型声明
2026-10-03 17:41:30 +08:00

32 lines
896 B
TypeScript

import { describe, expect, it } from 'vitest';
import {
countUiNodeDescendants,
findUiNode,
} from '../src/features/ui-editor/treeUtils';
import type { Node } from '../src/features/ui-editor/types/Node';
function node(id: string, children: Node[] = []): Node {
return {
id,
layout: {} as Node['layout'],
metadata: {} as Node['metadata'],
component: null,
children_display_mode: 'Stack',
children,
offset: {} as Node['offset'],
};
}
describe('ui tree utilities', () => {
it('finds a nested node and counts all descendants', () => {
const nested = node('nested', [node('leaf')]);
const root = node('root', [node('page'), nested]);
expect(findUiNode(root, 'nested')).toBe(nested);
expect(findUiNode(root, 'missing')).toBeNull();
expect(countUiNodeDescendants(nested)).toBe(1);
expect(countUiNodeDescendants(root)).toBe(3);
});
});