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

render_example_test.gno

1.46 Kb · 42 lines
 1package blog
 2
 3import "testing"
 4
 5// ExampleRender pins the index. It seeds state directly (rather than through
 6// Set) so the example takes no `cur realm`, and it resets first because an
 7// example runs after every Test in the package and would otherwise render what
 8// they left behind.
 9func ExampleRender() {
10	reset()
11	seed("mygnoscan", "Sharing mygnoscan", "2026-09-23", "mygnoscan,tooling", "An unfinished BI tool for gno.land.")
12	seed("hello", "Hello", "2026-09-01", "meta", "Starting a blog on chain.")
13	print(Render(""))
14	// Output:
15	// # moul's blog
16	//
17	// Notes on gno.land, from the person building on it.
18	//
19	// ## [Sharing mygnoscan](/r/moul/blog:mygnoscan)
20	//
21	// 2026-09-23 · [#mygnoscan](/r/moul/blog:t/mygnoscan) · [#tooling](/r/moul/blog:t/tooling)
22	//
23	// An unfinished BI tool for gno\.land\.
24	//
25	// ## [Hello](/r/moul/blog:hello)
26	//
27	// 2026-09-01 · [#meta](/r/moul/blog:t/meta)
28	//
29	// Starting a blog on chain\.
30}
31
32// TestNoticeBlocksAreTransparentByDefault pins the property that made it safe
33// to wrap every view in them: with nothing set on r/moul/config, Render is
34// byte-for-byte the inner render. If that ever stops holding, every page of
35// this blog gains stray whitespace at the top and the bottom.
36func TestNoticeBlocksAreTransparentByDefault(t *testing.T) {
37	for _, path := range []string{"", "t/gno", "no-such-post"} {
38		if Render(path) != render(path) {
39			t.Fatalf("Render(%q) differs from the inner render with no notice configured", path)
40		}
41	}
42}