import { describe, expect, it } from 'vitest';
import { applyTagPlaceholders, escapeHtml, pickRandomWinners } from './phase4.js';

describe('phase4 helpers', () => {
  it('picks unique random winners', () => {
    const winners = pickRandomWinners([1, 2, 3, 4, 5], 3);
    expect(winners).toHaveLength(3);
    expect(new Set(winners).size).toBe(3);
  });

  it('applies tag placeholders', () => {
    expect(applyTagPlaceholders('Hi {user} on {server}', { user: '<@1>', server: 'Nexumi' })).toBe(
      'Hi <@1> on Nexumi'
    );
  });

  it('escapes html', () => {
    expect(escapeHtml('<b>&"')).toBe('&lt;b&gt;&amp;&quot;');
  });
});
