package style8d

import (
	"strings"
	"testing"
)

func TestResolvePersonaBlockUsesPersonaDraftWhenPersonaEmpty(t *testing.T) {
	raw := `{"username":"demo","analysis":{"d1Tone":{"summary":"口語親近","evidence":[]}},"personaDraft":"【我是誰】\n生活觀察者"}`
	block := ResolvePersonaBlock("", raw, "")
	if block == "" {
		t.Fatal("expected non-empty block")
	}
	for _, part := range []string{"生活觀察者", "D1 語氣人格", "口語親近"} {
		if !strings.Contains(block, part) {
			t.Fatalf("block missing %q: %q", part, block)
		}
	}
}

func TestHasReady8DFromAnalysisOnly(t *testing.T) {
	raw := `{"analysis":{"d2Structure":{"summary":"短句開場","evidence":[]}}}`
	if !HasReady8D("", raw) {
		t.Fatal("expected ready from analysis summary")
	}
}
