| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 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 | } |
||
| 30 |