package docx

import (
	"strings"
	"testing"

	"mgit.msbls.de/m/paliad/pkg/docforge"
	"mgit.msbls.de/m/paliad/pkg/docforge/markdown"
)

func TestExporter_RenderBodyMatchesWalker(t *testing.T) {
	exp := NewExporter(map[string]string{"paragraph": "Body"}, nil)
	if exp.Format() != "docx" {
		t.Errorf("Format = %q; want docx", exp.Format())
	}
	if !strings.Contains(exp.MIMEType(), "wordprocessingml.document") {
		t.Errorf("MIMEType = %q", exp.MIMEType())
	}

	md := "Hello **world**\n\n- item"
	// The Exporter must produce exactly what the walker entry point does
	// for the same input (both go markdown.Import → RenderDocumentToOOXML).
	body, err := exp.RenderBody(markdown.Import(md))
	if err != nil {
		t.Fatalf("RenderBody: %v", err)
	}
	want := RenderMarkdownToOOXMLWithStyles(md, map[string]string{"paragraph": "Body"}, nil)
	if string(body) != want {
		t.Errorf("RenderBody mismatch:\n got %q\nwant %q", body, want)
	}
}

// satisfies the interface (compile-time check mirrored at runtime).
var _ docforge.Exporter = Exporter{}
