Skip to content

Commit

Permalink
optimize test
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmood committed May 23, 2022
1 parent 44a2a06 commit e1c9586
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 deletions hijack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ func TestHijackMockWholeResponseEmptyBody(t *testing.T) {
go router.Run()

// needs to timeout or will hang when "omitempty" does not get removed from body in fulfillRequest
timed := g.page.Timeout(2 * time.Second)
timed.MustNavigate("http://test.com")
timed := g.page.Timeout(time.Second)
timed.MustNavigate(g.Serve().Route("/", ".txt", "OK").URL())

g.Eq("", g.page.MustElement("body").MustText())
}
Expand All @@ -161,9 +161,8 @@ func TestHijackMockWholeResponseNoBody(t *testing.T) {
go router.Run()

// has to timeout as it will lock up the browser reading the reply.
timed := g.page.Timeout(2 * time.Second)
err := timed.Navigate("http://test.com")
g.True(errors.Is(err, context.DeadlineExceeded))
err := g.page.Timeout(time.Second).Navigate(g.Serve().Route("/", "").URL())
g.Is(err, context.DeadlineExceeded)
}

func TestHijackMockWholeResponse(t *testing.T) {
Expand Down
7 changes: 5 additions & 2 deletions page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,12 @@ func TestWindow(t *testing.T) {
page.MustWindowNormal()
page.MustWindowMinimize()
page.MustWindowNormal()

page.MustSetWindow(0, 0, 1211, 611)
g.Eq(1211, page.MustEval(`() => window.innerWidth`).Int())
g.Eq(611, page.MustEval(`() => window.innerHeight`).Int())
w, err := proto.BrowserGetWindowForTarget{}.Call(page)
g.E(err)
g.Eq(w.Bounds.Width, 1211)
g.Eq(w.Bounds.Height, 611)

g.Panic(func() {
g.mc.stubErr(1, proto.BrowserGetWindowForTarget{})
Expand Down

0 comments on commit e1c9586

Please sign in to comment.