Skip to content

Commit

Permalink
Async mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
inancgumus committed May 9, 2024
1 parent 97006d4 commit fa9d4de
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions browser/mouse_mapping.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
package browser

import (
"github.com/dop251/goja"

Check failure on line 4 in browser/mouse_mapping.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s prefix(github.com/grafana/xk6-browser) -s prefix(go.k6.io) -s default (gci)
"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
})
},
}
}

0 comments on commit fa9d4de

Please sign in to comment.