Skip to content

Commit

Permalink
modify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leohhhn committed Apr 26, 2024
1 parent 3cefc77 commit 8ca5956
Showing 1 changed file with 11 additions and 37 deletions.
48 changes: 11 additions & 37 deletions examples/gno.land/r/demo/userbook/userbook_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,15 @@ func TestGetSignupsInRange(t *testing.T) {

testCases := []struct {
name string
expectedRender string
nextPage bool
prevPage bool
path string
expectedNumberOfUsers int
}{
{
name: "Normal render",
expectedRender: `# Welcome to UserBook!
## UserBook - Page #1:
#### User #0 - g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm - signed up at Block #123
#### User #1 - g1w3jhxapsta047h6lta047h6lta047h6l2jx7pq - signed up at Block #123
#### User #2 - g1w3jhxap3ta047h6lta047h6lta047h6l4mfnm7 - signed up at Block #123
#### User #3 - g1w3jhxapjta047h6lta047h6lta047h6laqcyu4 - signed up at Block #123
#### User #4 - g1w3jhxapnta047h6lta047h6lta047h6lzfhfxt - signed up at Block #123
#### User #5 - g1w3jhxap5ta047h6lta047h6lta047h6ldlnrjr - signed up at Block #123
#### User #6 - g1w3jhxap4ta047h6lta047h6lta047h6ljkuwga - signed up at Block #123
#### User #7 - g1w3jhxapkta047h6lta047h6lta047h6l6dde0k - signed up at Block #123
#### User #8 - g1w3jhxaphta047h6lta047h6lta047h6l9yz54g - signed up at Block #123
#### User #9 - g1w3jhxapcta047h6lta047h6lta047h6lyg9dwx - signed up at Block #123
#### User #10 - g1w3jhxapeta047h6lta047h6lta047h6lmp2q5c - signed up at Block #123
#### User #11 - g1w3jhxap3xp047h6lta047h6lta047h6l0pgx4l - signed up at Block #123
#### User #12 - g1w3jhxap3x9047h6lta047h6lta047h6ls3mqfl - signed up at Block #123
#### User #13 - g1w3jhxap3xf047h6lta047h6lta047h6lcg82yl - signed up at Block #123
#### User #14 - g1w3jhxap3xd047h6lta047h6lta047h6l8c5vcl - signed up at Block #123
#### User #15 - g1w3jhxap3x3047h6lta047h6lta047h6lgnk77l - signed up at Block #123
#### User #16 - g1w3jhxap3x4047h6lta047h6lta047h6lhr9czl - signed up at Block #123
#### User #17 - g1w3jhxap3xe047h6lta047h6lta047h6ll6ej0l - signed up at Block #123
#### User #18 - g1w3jhxap3xa047h6lta047h6lta047h6lq225nl - signed up at Block #123
#### User #19 - g1w3jhxap38p047h6lta047h6lta047h6lac9qrr - signed up at Block #123
---
#### Total users: 21
#### Latest signup: User #20 at Block #123
---
You're viewing page #1 - [Next page](/r/demo/userbook:page/2)
`,
name: "Normal render",
nextPage: true,
prevPage: false,
path: "page/1",
expectedNumberOfUsers: 20,
},
Expand All @@ -68,8 +38,12 @@ You're viewing page #1 - [Next page](/r/demo/userbook:page/2)
t.Run("", func(t *testing.T) {
got := Render(tc.path)
numUsers := countUsers(got)
if got != tc.expectedRender {
t.Fatalf("Render not as expected, got:\n%s", got)

if tc.prevPage && !strings.Contains(got, "Previous page") {
t.Fatalf("expected to find Previous page, didn't find it")
}
if tc.nextPage && !strings.Contains(got, "Next page") {
t.Fatalf("expected to find Next page, didn't find it")
}

if tc.expectedNumberOfUsers != numUsers {
Expand Down

0 comments on commit 8ca5956

Please sign in to comment.