Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Improve Page.Evaluate test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed May 6, 2022
1 parent 7266f3a commit 72a7ff4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,21 @@ func TestPageEmulateMedia(t *testing.T) {
func TestPageEvaluate(t *testing.T) {
t.Parallel()

t.Run("ok/func", func(t *testing.T) {
t.Run("ok/func_arg", func(t *testing.T) {
t.Parallel()

tb := newTestBrowser(t)
p := tb.NewPage(nil)

got := p.Evaluate(tb.rt.ToValue("() => document.location.toString()"))
got := p.Evaluate(
tb.rt.ToValue("(v) => { window.v = v; return window.v }"),
tb.rt.ToValue("test"),
)

require.IsType(t, tb.rt.ToValue(""), got)
gotVal, _ := got.(goja.Value)
assert.Equal(t, "about:blank", gotVal.Export())
gotVal, ok := got.(goja.Value)
require.True(t, ok)
assert.Equal(t, "test", gotVal.Export())
})

t.Run("err", func(t *testing.T) {
Expand Down

0 comments on commit 72a7ff4

Please sign in to comment.