notify_test.gno
1.02 Kb · 30 lines
1package arena
2
3import (
4 "strings"
5 "testing"
6
7 "gno.land/p/nt/markdown/sanitize/v0"
8 "gno.land/p/nt/uassert/v0"
9 "gno.land/p/nt/urequire/v0"
10 "gno.land/r/nym-gfanton001/gnotif/v1"
11)
12
13func TestInitSetsTriggers(cur realm, t *testing.T) {
14 ids := strings.Split(gnotif.Active(self), ",")
15 urequire.Equal(t, 3, len(ids))
16 want := [][6]string{ // name, event, param, title, body, link
17 // The page opens the match a #match= fragment names.
18 {"turn", "Turn", "to", "Your move in Gnomepit", "{text}", pagePath + "#match={match}"},
19 {"ended", "Ended", "to", "Match over", "{text}", pagePath + "#match={match}"},
20 {"board", "Board", "", "Gnomepit challenges", "{text}", pagePath},
21 }
22 for i, w := range want {
23 page := gnotif.Render("trigger/" + ids[i])
24 for j, label := range []string{"Name", "Event", "Param", "Title", "Body", "Link"} {
25 // The registry renders each field through the same sanitizer.
26 line := "- " + label + ": " + sanitize.InlineText(w[j]) + "\n"
27 uassert.True(t, strings.Contains(page, line), ids[i]+" lacks "+line)
28 }
29 }
30}