import { readFileSync, readdirSync } from 'node:fs'; import { describe, expect, it } from 'vitest'; import { boardData } from '../src/board.js'; import { placeholders } from '../src/placeholders.js'; import { readManifest, readStyle, root } from './fixtures.js'; const manifest = readManifest(); const data = boardData(manifest, readStyle()); const stand = placeholders(manifest); const page = readFileSync(`${root}tools/art-prep/board/index.html`, 'utf8'); describe('the board data', () => { it('has the shape the board page reads', () => { for (const a of data.assets) { expect(a).toMatchObject({ id: expect.any(String), width: expect.any(Number), height: expect.any(Number), prompt: expect.any(String) }); expect(Array.isArray(a.usedBy) && Array.isArray(a.checks) && Array.isArray(a.attach)).toBe(true); if (a.type === 'spritesheet') { expect(a.cells).toHaveLength((a.grid?.cols ?? 0) * (a.grid?.rows ?? 0)); for (const c of a.cells ?? []) expect(c).toMatchObject({ id: expect.any(String), width: expect.any(Number), height: expect.any(Number), prompt: expect.any(String) }); } } expect(data.checklist).toHaveLength(8); }); it('every kind in the manifest has a group on the board page, or its cards would never show', () => { for (const type of new Set(data.assets.map((a) => a.type))) expect(page).toContain(`{ type: '${type}',`); }); it('the page takes the product name from @rosea/schema, never spells it', () => { expect(page).toContain('