package report import ( "html/template" "testing" ) func TestOffsetHTags(t *testing.T) { tests := []struct { name string html string amount int expected string }{ { name: "simple offset", html: `

Main

Sub

`, amount: 2, expected: `

Main

Sub

`, }, { name: "offset beyond h6", html: `
Almost max
Max
`, amount: 3, expected: `
Almost max
Max
`, }, { name: "negative offset", html: `

Heading

Subheading

`, amount: -2, expected: `

Heading

Subheading

`, }, { name: "no h tags", html: `

Paragraph

`, amount: 2, expected: `

Paragraph

`, }, { name: "mixed content", html: `

Title

Inner

`, amount: 1, expected: `

Title

Inner

`, }, { name: "real one", html: `

Hello

duration: 1h 43min

adökfjaösldkjflaa

ASDFADS

adllglggl

`, amount: 3, expected: `

Hello

duration: 1h 43min

adökfjaösldkjflaa

ASDFADS
adllglggl
`, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := offsetHTags(tt.amount, template.HTML(tt.html)) if string(got) != tt.expected { t.Errorf("OffsetHTags() = %q, want %q", got, tt.expected) } }) } }