ultisuite-backend/internal/api/richtext/document_test.go
R3D347HR4Y 20c4fef3c6
Some checks are pending
CI / Go tests (push) Waiting to run
CI / Integration tests (push) Waiting to run
CI / DB migrations (push) Waiting to run
docxi import lol
2026-06-10 00:27:21 +02:00

26 lines
853 B
Go

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)
}
})
}
}