package richtext

import "testing"

func TestIsEmptyDocContent(t *testing.T) {
	tests := []struct {
		name    string
		content string
		empty   bool
	}{
		{"blank", "", true},
		{"empty paragraph", `{"type":"doc","content":[{"type":"paragraph"}]}`, true},
		{"whitespace text", `{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"  "}]}]}`, true},
		{"has text", `{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Hello"}]}]}`, false},
		{"heading text", `{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"type":"text","text":"Title"}]}]}`, false},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got := isEmptyDocContent([]byte(tt.content))
			if got != tt.empty {
				t.Fatalf("isEmptyDocContent() = %v, want %v", got, tt.empty)
			}
		})
	}
}
