2024-06-09 09:31:30 -07:00
|
|
|
package handlers
|
2021-12-05 17:22:45 -08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2021-12-25 09:35:13 -08:00
|
|
|
// Simple example of how to test routes and their markup using the test HTTP server spun up within
|
|
|
|
// this test package
|
2024-06-09 09:31:30 -07:00
|
|
|
func TestPages__About(t *testing.T) {
|
2021-12-06 07:38:55 -08:00
|
|
|
doc := request(t).
|
2023-12-16 08:07:20 -08:00
|
|
|
setRoute(routeNameAbout).
|
2021-12-06 07:38:55 -08:00
|
|
|
get().
|
2021-12-06 04:42:20 -08:00
|
|
|
assertStatusCode(http.StatusOK).
|
|
|
|
toDoc()
|
|
|
|
|
2021-12-25 09:35:13 -08:00
|
|
|
// Goquery is an excellent package to use for testing HTML markup
|
2021-12-05 17:22:45 -08:00
|
|
|
h1 := doc.Find("h1.title")
|
|
|
|
assert.Len(t, h1.Nodes, 1)
|
|
|
|
assert.Equal(t, "About", h1.Text())
|
|
|
|
}
|