about summary refs log tree commit diff stats
path: root/assert/assert.go
blob: b18ff65f9a9304229f4d70dd15d0bec6a5eba4bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package assert

import (
	"strings"
	"testing"

	g "github.com/maragudk/gomponents"
)

// Equal checks for equality between the given expected string and the rendered Node string.
func Equal(t *testing.T, expected string, actual g.Node) {
	var b strings.Builder
	_ = actual.Render(&b)
	if expected != b.String() {
		t.Errorf("expected `%v` but got `%v`", expected, actual)
		t.FailNow()
	}
}

// Error checks for a non-nil error.
func Error(t *testing.T, err error) {
	if err == nil {
		t.FailNow()
	}
}