import { generateHTMLFromText } from 'src/utils/feed';

describe('generateHTMLFromText', () => {
  test('adds noopener and noreferrer for auto-generated links', () => {
    const html = generateHTMLFromText('Visit https://example.com', []);

    expect(html).toContain('target="_blank"');
    expect(html).toContain('rel="noopener noreferrer"');
    expect(html).toContain('href="https://example.com"');
  });

  test('adds noopener and noreferrer for generated mention links', () => {
    const html = generateHTMLFromText('@Alice', [
      {
        start: 0,
        length: 6,
        type: { user: { id: 123 } },
      },
    ]);

    expect(html).toContain('class="mention"');
    expect(html).toContain('target="_blank"');
    expect(html).toContain('rel="noopener noreferrer"');
  });
});
