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

Commit

Permalink
Add test for mouse DblClick
Browse files Browse the repository at this point in the history
This will help ensure that the DblClick behaviour matches the two
separate behaviours.
  • Loading branch information
ankur22 committed Dec 5, 2023
1 parent 70fec2a commit bf4f09f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/mouse_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package tests

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestMouseDblClick(t *testing.T) {
t.Parallel()

b := newTestBrowser(t, withFileServer())
p := b.NewPage(nil)
_, err := p.Goto(b.staticURL("dbl_click.html"), nil)
require.NoError(t, err)

p.Mouse.DblClick(35, 17, nil)

v := p.Evaluate(b.toGojaValue(`() => window.dblclick`))
assert.True(t, b.asGojaBool(v), "failed to double click the link")

got := p.InnerText("#counter", nil)
assert.Equal(t, "2", got)
}
26 changes: 26 additions & 0 deletions tests/static/dbl_click.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>

<head>
<title>Clickable link test</title>
</head>

<body>
<a id="linkdbl" href="#" ondblclick="event.preventDefault()" onclick="incrementCounter()">Dblclick</a>
Counter: <span id="counter">0</span>

<script>
window.dblclick = false;

document.querySelector('#linkdbl').addEventListener(
'dblclick', e => { window.dblclick = true }, false
);

var counter = 0;
function incrementCounter() {
document.getElementById("counter").textContent = ++counter;
}
</script>
</body>

</html>

0 comments on commit bf4f09f

Please # to comment.