Skip to content

Commit

Permalink
fix broken example
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed Jun 7, 2023
1 parent cd2a54a commit d9cfe8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions lib/examples/e2e-testing/calculator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package main

import "testing"

// test case: 1 + 2 = 3
const appURL = "https://go-rod.github.io/calculator/"

// test case: 1 + 2 = 3.
func TestAdd(t *testing.T) {
g := setup(t)

p := g.page("https://ahfarmer.github.io/calculator")
p := g.page(appURL)

p.MustElementR("button", "1").MustClick()
p.MustElementR("button", `^\+$`).MustClick()
Expand All @@ -18,11 +20,11 @@ func TestAdd(t *testing.T) {
g.Eq(p.MustElement(".component-display").MustText(), "3")
}

// test case: 2 * 3 = 6
// test case: 2 * 3 = 6.
func TestMultiple(t *testing.T) {
g := setup(t)

p := g.page("https://ahfarmer.github.io/calculator")
p := g.page(appURL)

// use for-loop to click each button
for _, regex := range []string{"2", "x", "3", "="} {
Expand Down
6 changes: 3 additions & 3 deletions lib/examples/e2e-testing/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"github.com/ysmood/got"
)

// test context
// test context.
type G struct {
got.G

browser *rod.Browser
}

// setup for tests
// setup for tests.
var setup = func() func(t *testing.T) G {
browser := rod.New().MustConnect()

Expand All @@ -27,7 +27,7 @@ var setup = func() func(t *testing.T) G {
}
}()

// a helper function to create an incognito page
// a helper function to create an incognito page.
func (g G) page(url string) *rod.Page {
page := g.browser.MustIncognito().MustPage(url)
g.Cleanup(page.MustClose)
Expand Down

0 comments on commit d9cfe8e

Please sign in to comment.