Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

pairreg_test.gno

0.95 Kb · 31 lines
 1package pairreg
 2
 3import (
 4	"strings"
 5	"testing"
 6
 7	"gno.land/p/nt/uassert/v0"
 8)
 9
10// Loaded on its own, the registry has no instances: the index says so rather
11// than rendering an empty table.
12func TestRenderEmpty(t *testing.T) {
13	out := Render("")
14	uassert.True(t, strings.Contains(out, "# AMM pairs"))
15	uassert.True(t, strings.Contains(out, "No instance yet"))
16	uassert.Equal(t, 0, Size())
17	uassert.Equal(t, 0, Couples())
18}
19
20func TestRenderUnknownInstance(t *testing.T) {
21	out := Render("gno.land/r/nope/v0")
22	uassert.True(t, strings.Contains(out, "# 404"))
23	uassert.True(t, Get("gno.land/r/nope/v0") == nil)
24	uassert.Equal(t, 0, len(InstancesFor("a~b")))
25}
26
27// A gnoweb link is the package path minus the chain domain.
28func TestWebPath(t *testing.T) {
29	uassert.Equal(t, "/r/nym-moultest123/x/pairs/aaabbb/v0", webPath("gno.land/r/nym-moultest123/x/pairs/aaabbb/v0"))
30	uassert.Equal(t, "r/moul/x/pairs/aaabbb/v0", shortPath("gno.land/r/nym-moultest123/x/pairs/aaabbb/v0"))
31}