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(); }); });