// Session 42 — StatStrip (.tsx asserted as text; the design's hard rules are
// structural so they're verifiable in source).

const fs = require('fs');
const path = require('path');
const WEB = path.join(__dirname, '..', '..', 'web', 'src');
const src = fs.readFileSync(path.join(WEB, 'components', 'vyndr', 'StatStrip.tsx'), 'utf8');

describe('StatStrip.tsx', () => {
  it('renders the player name ONCE (single PlayerName helper, not per-stat)', () => {
    // PlayerName is defined once and the stats map never references `player`.
    const playerNameUses = (src.match(/<PlayerName/g) || []).length;
    expect(playerNameUses).toBeGreaterThan(0);
    // the stat row maps over `stats`, not the player name
    expect(src).toMatch(/stats\.map/);
    expect(src).not.toMatch(/stats\.map[\s\S]{0,80}\{player\}/);
  });

  it('lays stats out horizontally with mono + separators (no vertical repetition)', () => {
    expect(src).toContain('className="mono"');
    expect(src).toContain('const Sep =');
    expect(src).toMatch(/flexWrap: 'wrap'/);
  });

  it('renders props inline with GradeBadge', () => {
    expect(src).toContain('GradeBadge');
    expect(src).toMatch(/props\.map/);
    expect(src).toContain('PROPS');
  });

  it('expanded variant shows archetype badge(s)', () => {
    expect(src).toContain("variant === 'expanded'");
    expect(src).toContain('ArchetypeBadge');
    expect(src).toContain('showDesc');
  });

  it('supports an onPlayerClick navigation hook (keyboard accessible)', () => {
    expect(src).toContain('onPlayerClick');
    expect(src).toContain('onKeyDown');
    expect(src).toContain("role=\"link\"");
  });

  it('compact variant supports primary + secondary archetypes', () => {
    expect(src).toContain('archetype.primary');
    expect(src).toContain('archetype?.secondary');
    expect(src).toContain("variant=\"ghost\"");
  });
});
