import { test, expect } from 'bun:test';
import { createCompiler } from '../index.js';
const compiler = createCompiler({});
test('compile() handles images', () => {
const input = '';
const result = compiler.compile(input, '/virtual.md', {});
// HTML is now inside a JSON string (via set:html), so quotes are escaped
expect(result.code.includes('alt=\\"alt\\"')).toBe(true);
expect(result.code.includes('src=\\"image.png\\"')).toBe(true);
});
test('compile() handles raw HTML img tags', () => {
const input = '
';
const result = compiler.compile(input, '/virtual.md', {});
// Raw HTML is converted to JSX spread format
expect(result.code.includes('img')).toBe(true);
expect(result.code.includes('/hero.png')).toBe(true);
});
test('compile() keeps lowercase JSX href as HTML inside set:html', () => {
const input = 'docs';
const result = compiler.compile(input, '/virtual.mdx', {});
expect(result.code.includes('docs')).toBe(true);
expect(result.code.includes('href={\\"https://example.com?a=1&b=2\\"}')).toBe(false);
});
test('compile() embeds component href props as direct JSX instead of set:html', () => {
const input = 'import Card from "./Card.astro"\n\n