zz_links_test.gno
0.64 Kb · 30 lines
1package polls
2
3import (
4 "strings"
5 "testing"
6
7 "gno.land/p/nt/testutils/v0"
8 "gno.land/p/nt/uassert/v0"
9)
10
11// A poll page links back to this realm. It once linked to
12// /r/REPLACE_ADDR/polls.
13func TestPollPageLinksBackToThisRealm(cur realm, t *testing.T) {
14 testing.SetRealm(testing.NewUserRealm(testutils.TestAddress("linker")))
15 id := CreatePoll(cross(cur), "Linked?", "yes,no")
16 page := Render(itoaTest(id))
17 uassert.True(t, strings.Contains(page, "[← all polls](/r/moul/x/daily/polls/v1)"), page)
18}
19
20func itoaTest(n int) string {
21 if n == 0 {
22 return "0"
23 }
24 s := ""
25 for n > 0 {
26 s = string(rune(byte(n%10)+byte(48))) + s
27 n /= 10
28 }
29 return s
30}