-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97006d4
commit fa9d4de
Showing
1 changed file
with
28 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
package browser | ||
|
||
import ( | ||
"github.com/dop251/goja" | ||
"github.com/grafana/xk6-browser/common" | ||
"github.com/grafana/xk6-browser/k6ext" | ||
) | ||
|
||
func mapMouse(_ moduleVU, m *common.Mouse) mapping { | ||
func mapMouse(vu moduleVU, m *common.Mouse) mapping { | ||
return mapping{ | ||
"click": m.Click, | ||
"dblClick": m.DblClick, | ||
"down": m.Down, | ||
"up": m.Up, | ||
"move": m.Move, | ||
"click": func(x float64, y float64, opts goja.Value) *goja.Promise { | ||
return k6ext.Promise(vu.Context(), func() (any, error) { | ||
return nil, m.Click(x, y, opts) //nolint:wrapcheck | ||
}) | ||
}, | ||
"dblClick": func(x float64, y float64, opts goja.Value) *goja.Promise { | ||
return k6ext.Promise(vu.Context(), func() (any, error) { | ||
return nil, m.DblClick(x, y, opts) //nolint:wrapcheck | ||
}) | ||
}, | ||
"down": func(opts goja.Value) *goja.Promise { | ||
return k6ext.Promise(vu.Context(), func() (any, error) { | ||
return nil, m.Down(opts) //nolint:wrapcheck | ||
}) | ||
}, | ||
"up": func(opts goja.Value) *goja.Promise { | ||
return k6ext.Promise(vu.Context(), func() (any, error) { | ||
return nil, m.Up(opts) //nolint:wrapcheck | ||
}) | ||
}, | ||
"move": func(x float64, y float64, opts goja.Value) *goja.Promise { | ||
return k6ext.Promise(vu.Context(), func() (any, error) { | ||
return nil, m.Move(x, y, opts) //nolint:wrapcheck | ||
}) | ||
}, | ||
} | ||
} |