48caa23997
canvas生成与运行时统一使用共享GameCreationAppAssetKind 删除平台kind兼容映射与退役kind拒绝测试 更新资源kind审计里程碑与绑定文档
41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import {
|
|
GAME_CREATION_APP_ASSET_KINDS,
|
|
parseGameCreationAppAssetKind,
|
|
} from '../../../packages/shared/src/contracts/gameCreationApp';
|
|
|
|
describe('shell generated asset kind boundary', () => {
|
|
it('keeps the generated kind values aligned with the manifest vocabulary', () => {
|
|
expect(GAME_CREATION_APP_ASSET_KINDS).toContain('font');
|
|
expect(GAME_CREATION_APP_ASSET_KINDS).toContain('audio');
|
|
expect(GAME_CREATION_APP_ASSET_KINDS).toContain('sound-effect');
|
|
expect(GAME_CREATION_APP_ASSET_KINDS).toContain('background-music');
|
|
expect(GAME_CREATION_APP_ASSET_KINDS).toContain('unknown');
|
|
});
|
|
|
|
it('records non-canonical input as unknown', () => {
|
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
expect(
|
|
parseGameCreationAppAssetKind('future-kind', 'manifest.asset.kind'),
|
|
).toBe('unknown');
|
|
expect(warn).toHaveBeenCalledWith(
|
|
'未知的 GameCreationApp 资源 kind,已收口为 unknown',
|
|
{ rawKind: 'future-kind', sourceContext: 'manifest.asset.kind' },
|
|
);
|
|
warn.mockRestore();
|
|
});
|
|
|
|
it('records the input type instead of stringifying non-string input', () => {
|
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
expect(parseGameCreationAppAssetKind(null, 'manifest.asset.kind')).toBe(
|
|
'unknown',
|
|
);
|
|
expect(warn).toHaveBeenCalledWith(
|
|
'GameCreationApp 资源 kind 不是字符串,已收口为 unknown',
|
|
{ rawType: 'object', sourceContext: 'manifest.asset.kind' },
|
|
);
|
|
warn.mockRestore();
|
|
});
|
|
});
|