Completed
Push — main ( d205ff...d7083f )
by Yume
24s queued 13s
created

page_test.TestHero   A

Complexity

Conditions 4

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nop 1
dl 0
loc 16
rs 9.85
c 0
b 0
f 0
1
package page_test
2
3
import (
4
	"context"
5
	"io"
6
	"testing"
7
8
	"github.com/PuerkitoBio/goquery"
9
	"github.com/memnix/memnix-rest/app/v2/views/page"
10
)
11
12
func TestHero(t *testing.T) {
13
	r, w := io.Pipe()
14
	const name = "John"
15
	go func() {
16
		_ = page.Hero(name).Render(context.Background(), w)
17
		_ = w.Close()
18
	}()
19
20
	doc, err := goquery.NewDocumentFromReader(r)
21
	if err != nil {
22
		t.Fatalf("Error reading document: %s", err)
23
	}
24
25
	// Assert that the hero exists
26
	if doc.Find(`[data-testid="hero"]`).Length() != 1 {
27
		t.Errorf("Expected to find a hero")
28
	}
29
}
30