import { describe, expect, it } from 'vitest'; import type { Package } from '@tts/bgm'; import { expandSetupValue, seedFromSetup } from './setup.js'; const pkg: Package = { meta: { id: 'harbor' }, parts: new Map([ ['token#wood', { type: 'token', id: 'wood' }], ['token#grain', { type: 'token', id: 'grain' }], ['card#fleet', { type: 'card', id: 'fleet' }], ]), surfaces: new Map([ ['board#harbor', { type: 'board', id: 'harbor', layout: [] }], ['hud#hand', { type: 'hud', id: 'hand', layout: [] }], ]), setups: new Map(), }; describe('expandSetupValue', () => { it('keeps a full part id', () => { expect(expandSetupValue(pkg, 'harbor:card#fleet')).toEqual(['harbor:card#fleet']); }); it('expands a bare type to all parts of that type', () => { expect(expandSetupValue(pkg, 'harbor:token')).toEqual(['harbor:token#wood', 'harbor:token#grain']); }); it('expands each entry of a list', () => { expect(expandSetupValue(pkg, ['harbor:card#fleet', 'harbor:token'])).toEqual([ 'harbor:card#fleet', 'harbor:token#wood', 'harbor:token#grain', ]); }); }); describe('seedFromSetup', () => { it('enables listed surfaces and places parts', () => { const setup = { type: 'game', id: 'main', surfaces: ['board#harbor'], setup: { '/deck': 'harbor:card#fleet' }, }; const state = seedFromSetup(pkg, setup); expect(state.surfaces).toEqual({ 'board#harbor': true }); expect(state.paths).toEqual({ '/deck': ['harbor:card#fleet'] }); }); it('enables all surfaces when omitted', () => { const setup = { type: 'game', id: 'main', setup: {} }; const state = seedFromSetup(pkg, setup); expect(state.surfaces).toEqual({ 'board#harbor': true, 'hud#hand': true }); }); });